JS Fundamentals Flashcards

1
Q

To declare a variable

A

Use var, let, const

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

=

A

Assignment Operator

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

Another word for the starting value of a variable

A

The variable is initialized with [blank]

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

mathematical assignment operators

A

+=, -=, *=, /=
perform a mathematical operation to the variable, then reassign that value to the variable
ex: z += 1 is the same as z = z + 1

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

Increment and Decrement Operator

A

++, –
another mathematical assignment operator
the variable’s value is updated and assigned as the new value of that variable
increment operator - increases the value of the variable by 1
decrement operator - decreases the value of the variable by 1
ex:
let a = 10;
a++; // => a = 11;

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

String Interpolation

A
interpolate (or insert) variables into strings using template literals
ex: const myPet = 'armadillo';
console.log(`I own a pet ${myPet}.`);
- template literal is wrapped by backticks
- Inside the template literal, you'll see a placeholder, ${myPet}. The value of myPet is inserted into the template literal
- When we interpolate `I own a pet ${myPet}.`, the output we print is the string: 'I own a pet armadillo.'
Using template literals, you can more easily tell what the new string will be. You also don't have to worry about escaping double quotes or single quotes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

typeof operator

A

checks the value to its right and returns, or passes back, a string of the data type

ex: const unknown1 = ‘foo’;
console. log(typeof unknown1); // Output: string

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

Conditional Statements

A

checks specific condition(s) and performs a task based on the condition(s)
if and if/else statements

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

Comparison Operators

A

operators to compare values
>, =, <=, ===, !==
evaluate to either true or false

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

Logical Operators

A

&&, ||

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