JS Course 1: Fundamental 2 Flashcards
Name the eight data types in JavaScript.
Strings, Numbers, BigInt (big integers), Boolean, Undefined, Null, Symbol, and Objects.
Which data type is not primitive?
Objects and Symbols are not primitive because they can hold many things or bits of information.
What is the relationship between null and undefined?
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.
What are the differences between single, double, and backtick quotes?
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 do you use escape characters in a string?
Using \ either right before a single character you want to use or using ...\ to nest texts you want to escape.
What is the difference between the slice(), substring(), and substr() string methods?
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.
What are the three logical operators and what do they stand for?
|| OR
&& AND
! NOT
What are the comparison operators?
< 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)
What are truthy and falsy values?
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.
What are the falsy values in JavaScript?
””, 0, undefined, null, and NaN
What are conditionals?
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.
What is the syntax for an if…else statement?
if (condition) {
// code
} else {
// code
}
What is the syntax for a switch statement?
switch (condition) {
case text1:
// code
break;
// repeat for how many cases are needed
default:
// default code if cases aren’t met
}
What is the syntax for a ternary operator?
condition ? /* run this code if true / : / run this code if false */
What is nesting?
Nesting (in the context of conditionals) is putting a conditional inside another conditional.