Intro to JavaScript Flashcards

(65 cards)

1
Q

What is console?

A

A keyword that refers to an object, a collection of data and actions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a keyword?

A

Words that are built into the JavaScript language so the computer will recognize them and treats them specifically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to use .log()

A

console.log() - what is put in the parenthesis will get printed/logged in the console.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 7 fundamental data types?

A

Number, String, Boolean, Null, Undefined, Symbol, Object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an undefined data type?

A

It represents the absence of a value though it has a different use than NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a symbol data type?

A

Unique identifiers, useful in more complex coding.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an object data type?

A

Collections of related data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Are number data types allowed decimals?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a variable?

A

You can think of a variable as a container for a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the few things you can do with variables?

A
  1. Create a variable with a descriptive name
  2. Store or update information stored in a variable
  3. Reference or “get” information stored in a variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does var do?

A

Keyword that creates, or declares, a new variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are rules of naming variables?

A
  1. Variable names cannot start with numbers
  2. Variable names are case sensitive
  3. Variable names cannot be the same as keywords
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the let keyword allow for?

A

This keyword signals that the variable can be reassigned a different value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What value does a var have if we initiate it without a value?

A

Undefined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the const keyword do?

A

Create a variable that cannot be reassigned. These must be assigned a variable when they are declared.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a template literal?

A
A function(?) that lets you add variables into strings.
Must use ~ instead of '.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Give an example of a template litera?

A

console.log(My name is ${variable})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Example of an if statement

A

if (false) {

console.log(‘The code in this block will not run.’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What operator do you use to say “Is equal to”?

A

===

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What operator do you use to say “Is not equal to”?

A

!==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What does the and operator look like?

A

&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What does the or operator look like?

A

||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What does the not operator look like?

A

!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Which values are falsy or evaluate to falsy?

A

0, Empty strings like “” or ‘’, null, undefined, Nan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the syntax to a switch statement?
switch (groceryItem) { case 'tomato': console.log('Tomatoes are $0.49'); break;
26
What is one way of declaring a function?
By using the keyword function followed by the name of the function. function your name() {}
27
When does a function execute?
When the function is called. You need to type toe function followed by (). Example, function();
28
What do parameters do in a function?
Allow functions to accept input(s) and perform a task using the input(s). They are placeholders for information that will be passed to the function when it is called.
29
What is a default parameter?
Default parameters allow parameters to have a predetermined value in case there is no argument passed into the function or if the argument is undefined when called.
30
What does a zero parameter FAT ARROW function look like?
const funcitonName = () => {};
31
What does a one parameter FAT Arrow function look like?
const functionName = paramOne => {};
32
What does a two parameter FAT ARROW function look like?
const functionName = (paramOne, paramTwo) => {};
33
What does a function body compopsed of a single-line block look like?
const sumNumbers = number => number + number;
34
What does a function body composed of a multiple lines of block look like?
``` const sumNumbers = number => { const sum = number + number; return sum; }; ```
35
What does scope do?
Scope defines where variables can be accessed or referenced.
36
What are blocks?
A block is the code found inside a set of curly braces {}. They help us group one or more statements together and serve as an important structural marker for our code.
37
Where is a global scope declared?
Global scope variables are declared outside of blocks | This allows them to be accessed by any code in the program.
38
What is block scope?
context within which variables that are accessible only within the block they are defined.
39
What is Scope Pollution?
When you have too many global variables that exist in the global namespace. Or when we reuse variables across different scopes.
40
What are local variables?
Variables that exist within block scope
41
What is an array?
Javascript's way of making lists.
42
What is the syntax for an array?
['content of array', 'content 2 of array', 'array can have numbers', 10]
43
What is the content item inside an array called?
An element
44
What is the name of the numbered position of each element?
Index
45
What does the .length property let you know about an array?
It lets you know how many elements are in an array. it is used by adding .length to the end of an array/variable. variable.length
46
What does the.push() method allow us to do?
It allows us to add items to the end of an array
47
Example of the .push() method
const itemTracker = ['item 0'] itemTracker.push('item 3') console.log(itemTracker) // returns ['item 0', ' item 3']
48
What does the .pop() method do?
The .pop() method removes the last item of an array.
49
What does the .shift() method do?
It removes the first item from an array
50
What does the .unshift() method do?
It takes an argument .unshift('argument') and adds it to the beginning of an array. Can take multiple arguments.
51
What is a loop?
Programming tool that repeats a set of instructions until a specified condition, called a stopping condition, is reached.
52
What are the 3 expressions contained in all for loops?
1. Initialization (what starts the loop) 2. stopping condition (condition that the iterator variable is evaluated against) 3. Iteration statement (used to update the iterator variable on each loop)
53
Tell me what the syntax for a for loop should look like?
``` for (let i = 0; i < bobsFollowers.length; i++){ for (let j = 0; j < tinasFollowers.length; j++){ if(bobsFollowers[i] === tinasFollowers[j]){ mutualFollowers.push(bobsFollowers[i]) } } } ```
54
When to use a for loop?
We use a for loop when we know how many times the loop should run
55
What is a higher-order function?
Higher-Order-Functions are functions that accept other functions as arguments and/or return functions as output.
56
What are callback functions?
Functions that get passed in as parameters and invoked. This is because they get called during the execution of the higher-order function
57
What does the this keyword reference?
It references the CALLING object which provides access to the CALLING object's properties
58
What type of formatting should you avoid when using the THIS keyword
BIG ARROW formatting - forces the function to bind in the GLOBAL environment rather than the CALLING object.
59
What are GETTERS?
Getters are methods that get and return the internal properties of an object.
60
What are SETTERS?
Methods that reassign values of existing properties within an object.
61
What are factory functions?
a function that returns an object and can be reused to make multiple object instances. They can also have parameters allowing us to customize the object that gets returned.
62
What are classes in JS?
Classes are a tool that developers use to quickly produce similar objects.
63
What is an instance in JS?
An instance is an object that contains the property names and methods of a class but with unique property values.
64
What does the "Extends" keyword do in a class?
Makes the methods of a class available inside the new class.
65
What does the "super" keyword do in a constructor argument?
IT helps pass the argument past the first class and onto the parent class. Note: You must always call the super method before you can use the this keyword.