Types in JS Flashcards

1
Q

Null

A

Absence of value

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

Undefined

A

absence of definition

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

What are the 7 JS falsy values?

A
  1. false
  2. null
  3. undefined
  4. 0
  5. NaN
  6. ””
  7. document.all
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are primitive types?

A

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.

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

What are the 7 basic types in JS?

A
  1. number for numbers of any kind: integer or floating-point.
  2. string for strings. A string may have one or more characters, there’s no separate single-character type.
  3. boolean for true/false.
  4. null for unknown values – a standalone type that has a single value null.
  5. undefined for unassigned values – a standalone type that has a single value undefined.
  6. object for more complex data structures.
  7. symbol for unique identifiers.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain how objects are stored and copies “by reference”

A

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

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

What is the difference between == and ===?

A

== 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly