Primitive & Reference Types Flashcards

1
Q

What are the primitive types?

A

Number, String, Boolean, Symbol, Undefined, and Null are all primitive values.

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

What are the reference types?

A

Objects, Functions, and Arrays are all reference objects.

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

What is the difference between primitive and reference types?

A

Primitive values are stored in the stack, reference values like objects are stored on the heap.

Reference values know where the pointer to the value is, not the value itself. So, if the value in memory is changed the value returned by the reference type will be different

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

What is the number returned to the console?

let number = 10;
function increase(number) {
    number++;
}
increase(number);

console.log(number);
A
>>> 10
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the number returned to the console?

let obj = {value: 10}
function increase(obj) {
    obj.value++;
}
increase(obj);

console.log(number)
A
>>> {value: 11}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly