Objects and OOP Flashcards

(10 cards)

1
Q

How to access an object’s property?

A

Dot notation: obj.property

Bracket notation: obj[“property”] or obj[variable]

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

How to delete a property?

A

delete obj.property

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

How to check, if a property with a given key exists?

A

“key” in obj

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

How to iterate over an object?

A

for (let key in obj)

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

How are objects saved?

A

They are stored in memory by reference. The variable does not store the value but the reference for the value.

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

How to copy an object?

A

Object.assign() or _.cloneDeep(obj)

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

What are methods?

A

Functions stored in objects.

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

How can methods reference the object?

A

With the keyword “this”.

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

What is “this”?

A

A special variable defined at run-time. Most of the time it’s referencing to the object “left of the dot”.

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

What is so special about arrow functions and “this”?

A

Arrow functions do not have “this”. A “this” inside an arrow function references to the outer scope.

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