Types in JS Flashcards
Null
Absence of value
Undefined
absence of definition
What are the 7 JS falsy values?
- false
- null
- undefined
- 0
- NaN
- ””
- document.all
What are primitive types?
Values can contain only a single thing (versus Objects, non-primitive) that are used to store collections of data and more complex entities.
It is immutable, can’t be broken down further.
What are the 7 basic types in JS?
- number for numbers of any kind: integer or floating-point.
- string for strings. A string may have one or more characters, there’s no separate single-character type.
- boolean for true/false.
- null for unknown values – a standalone type that has a single value null.
- undefined for unassigned values – a standalone type that has a single value undefined.
- object for more complex data structures.
- symbol for unique identifiers.
Explain how objects are stored and copies “by reference”
A variable stores not the object itself, but its “address in memory”, in other words “a reference” to it.
When an object variable is copies – the reference is copied, the object is not duplicated.
Passing by reference saves space in memory.
https://javascript.info/object
What is the difference between == and ===?
== is the abstract equality operator while === is the strict equality operator. The == operator will compare for equality after doing any necessary type conversions. The === operator will not do type conversion, so if two values are not the same type === will simply return false. When using ==, funky things can happen, such as:
1 == '1'; // true 1 == [1]; // true 1 == true; // true 0 == ''; // true 0 == '0'; // true 0 == false; // true