The Secret Life of Objects Flashcards
Encapsulation
Distinguishing between internal complexity and external interface.
What is a method?
Properties that hold function values. rabbit.special = function(arg) { //statement }
T or F: Almost all objects have prototypes.
True
What is a prototype?
Another object that is used as a fallback source of properties.
What happens when an object gets a request for a property that it does not have?
Its prototype will be searched for the property, then the prototype’s prototype, and so on.
Object.create()
Creates an object with a specific prototype in the argument.
Calling a function with the “new” keyword in front of it causes it to be treated as a _______.
Constructor
An object created with the “new” keyword is said to be an ______ of its constructor.
instance
What should you always do when naming a constructor so it can be easily distinguished from other functions?
Capitalize the first letter of the constructor name.
Constructors (all functions) automatically get a property named _____.
prototype
By default, prototypes created through constructors get?
a plain, empty object that derives from Object.prototype. Every instance created with this constructor will have this object as its prototype.
Object’s prototype can be retrieved with?
Object.getPrototypeOf
The actual prototype of a constructor is?
Function.prototype (since constructors are functions)
Can instance object’s properties override it’s prototype properties?
Yes
What are enumerable properties?
Properties that we create by simply assigning to them.
The standard properties in Object.prototype are enumerable or non-enumerable?
non-enumerable.
How can we define our non-enumerable properties?
Object.defineProperty() function. Allows us to control the type of property we are creating.
What does the “hasOwnProperty()” method do?
Tells us whether the object itself has the property, without looking at its prototype.