JavaScript Basics Module #16 Flashcards

1
Q

What kind of error do you get if you try to reassign a new value to a const variable?

A

TypeError

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

Which 2 use cases can a const variable point to in which the content changes?

A

Object or Array

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

Which kind of variable should be used most often and why?

A

const because the less power our code has the better. This way, less bugs are introduced into our program.

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

What are the 4 primitive types?

A

Numbers, strings, booleans, symbols. There are also 2 special types, “null” and “undefined”.

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

What is an object type?

A

Any value that is not a primitive: (string, number, boolean or property).

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

What’s an expression?

A

A single unit of JS code that the JavaScript engine can evaluate.

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

Logical Expressions have 3 types, what are they?

A

&& (and) | | (or) !a (not)

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

What happens in JS when you divide a number by 0?

A

No error is returned, instead the value of Infinity or (-Infinity) is returned.

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

What is returned by this expression 1 % 0?

A

NaN (Not a Number)

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

What is returned by this expression -1 % 0?

A

NaN (Not a Number) Any time you use the remainder operator on a zero, it returns NaN.

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

How is the exponentiation operator expressed?

A

**

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

In JavaScript what is the order of operations for operators?

A

Multiplication, Division, Remainder, addition and subtraction. Anything inside of parenthesis are evaluated first.

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

What are the equality operators?

A

===Equality strict, !== Inequality strict (also == eqaulity and != inequality operator) *Strongly suggested to only use the strict operators ( less errors and less problems that are difficult to troubleshoot/diagnose)

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

How do you set up an if statement?

A
if (condition true){
// do something
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you set up an if /else statement?

A
if (condition true){
// do something
} else {
//do something else
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you set up an “else if” statement inside of an “if” statement? Don’t forget to include the fallback.

A
if ( a === true ) {
//do something
} else if ( b === true ) {
//do something else
} else {
// fallback
}