Objects Flashcards

1
Q

What is an object?

A

A collection of key:value pairs.

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

What is object literal syntax?

A

const circle = { } ;

Under the hood, it is created using the built in object constructor function:

const circle = new Object( );

(the same happens with strings, boolean)

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

What is a method?

A

A function used to define some logic within an object

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

What is a property?

A

Properties are used to hold values within an object

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

What are the two ways to create an object in OOP?

A

Constructor function (using this. & new)

Factory function (using return & does not use .this)

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

Why is there a constructor property on each object in OOP?

A

Every object has a constructor function property because it references the function that was used to create it

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

What is a getter?

A

A getter is a function that is used to read a property.

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

What is a setter?

A

You create a setter which allows you to set the value of a property / throw errors if the value is not what is to be expected

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