JS Course 1: Fundamental 2 Flashcards

1
Q

Name the eight data types in JavaScript.

A

Strings, Numbers, BigInt (big integers), Boolean, Undefined, Null, Symbol, and Objects.

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

Which data type is not primitive?

A

Objects and Symbols are not primitive because they can hold many things or bits of information.

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

What is the relationship between null and undefined?

A

Null and undefined have specific, unique interactions when compared to each other! It’s good to know what they do and how to prevent having these two values compared.

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

What are the differences between single, double, and backtick quotes?

A

Single and double quotes are interchangeable and are used to indicate strings. Example: ‘string’ and “string”

Backtick quotes are specifically used when you want to embed a variable, function, etc. in your string using ${…}. These quotes are also called template literals.

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

How do you use escape characters in a string?

A

Using \ either right before a single character you want to use or using ...\ to nest texts you want to escape.

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

What is the difference between the slice(), substring(), and substr() string methods?

A

slice() extracts a part of a string taking two arguments that are numbers representing the index number of the string. Can also take negative numbers to start from the end of the string.

substring() is like slice() but instead does not take negative values.

substr() is like slice(), but the first argument instead determines where the first part of the extraction is and the second argument is how long/how many characters ahead the method will extract.

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

What are the three logical operators and what do they stand for?

A

|| OR
&& AND
! NOT

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

What are the comparison operators?

A

< Less Than
> Greater Than
<= Less than or equal to
>= Greater than or equal to
!= Not equal to
== Equal to (the same as)
=== Strict Equality (more strict than the one above)

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

What are truthy and falsy values?

A

Truthy and falsy values are values that evaluate to true or false in a boolean context, thought the value does/may not have an intrinsic value.

Example: and empty string “” is false.

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

What are the falsy values in JavaScript?

A

””, 0, undefined, null, and NaN

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

What are conditionals?

A

Conditionals are statements that test if a condition is true or false to run code. If true, the code runs. If false, it doesn’t.

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

What is the syntax for an if…else statement?

A

if (condition) {
// code
} else {
// code
}

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

What is the syntax for a switch statement?

A

switch (condition) {
case text1:
// code
break;

// repeat for how many cases are needed

default:
// default code if cases aren’t met
}

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

What is the syntax for a ternary operator?

A

condition ? /* run this code if true / : / run this code if false */

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

What is nesting?

A

Nesting (in the context of conditionals) is putting a conditional inside another conditional.

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