Objects Flashcards
What is an object?
A collection of key:value pairs.
What is object literal syntax?
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)
What is a method?
A function used to define some logic within an object
What is a property?
Properties are used to hold values within an object
What are the two ways to create an object in OOP?
Constructor function (using this. & new)
Factory function (using return & does not use .this)
Why is there a constructor property on each object in OOP?
Every object has a constructor function property because it references the function that was used to create it
What is a getter?
A getter is a function that is used to read a property.
What is a setter?
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