Object Oriented JavaScript & Prototypal Inheritance Flashcards
Inheritance
One object gets access to the properties and methods of another object. (There’s an object and another object, an the other object can get access to the first object’s methods and properties.)
Classical Inheritance
Verbose. A large collection of object’s properties and methods.
Prototypal Inheritance
Simpler than classical inheritance. It’s flexible, extensible, and easier to understand.
Objects can have
properties and methods.
Everything in JavaScript except for _____ are objects.
primitives: numbers, strings, booleans, undefined, null.
Reflection
An object can look at itself, listing and changing its properties and methods.
Every constructor we initialize gets a free ______ object as one of its properties.
prototype
What is object-oriented programming?
Objects interacting with one another through methods and properties. Used to store data, structure applications into modules and keeping code clean.
Constructors act like a ________.
blueprints
Inheritance is made possible because of the ______ that every object has.
prototype
How does inheritance actually work?
prototype chain. When you try to access method or property on a object, JS will first try to find it in that object.. if it can’t find it, then it looks at the parent’s object, if the method is still not there, it continues to look at the upper objects until it’s null/undefined.
Every JavaScript object has a ______ _____, which makes inheritance possible in JavaScript.
prototype property
The prototype property of an object is where we put methods and properties that we want other objects to _____.
inherit
The constructor’s prototype property is NOT the prototype of the Constructor itself, it’s the prototype of ALL _______ that are created through it.
instances
When a certain method (or property) is called, the search starts in the object itself, and if it cannot be found, the search moves on to the object’s prototype. This continues until the method is found. This is called?
The prototype chain