Javascript Flashcards
What are 7 built-in types in JavaScript (ES6)?
null, undefined, boolean, number, string, object, and symbol.
All are primitives except for object
Null vs. Undefined?
Undefined is the absence of a definition. It is used as the default value for uninitialized variables, function arguments that were not provided and missing properties of objects.
- Functions return undefined when nothing has been explicitly returned.
Null is the absence of a value. It is an assignment value that can be assigned to a variable as a representation of ‘no-value’.
Implicit Coercion. Boolean coercion. What is falsy and what is truthy?
Falsy values: “”, 0, null, undefined, NaN, false.
Truthy: everything else. Empty arrays, objects, and functions are coerced to true.
String & Number coercion. What can you tell me?
The + operator works for both strings and numbers.
The *, /, and - operators are exclusive for numeric operations. When strings use these, they will be coerced to a number.
If a + is used with strings and numbers, they will be coerced into a string.
== vs. ===
== checks for equality with coercion. === checks for equality without coercion. strict equality.