Object-oriented Programming in JS Flashcards
(109 cards)
What are the 4 pillars of OOP
Encapsulation
Abstraction
Polymorphism
Inheritance
what is Encapsulation?
group related variable and functions together and reuse
What is Abstraction?
hide details and complexity and only show essentials
What is Inheritance?
eliminate redundant code
What is Polymorphism?
allows code to change
what is a function in an object called?
method.
the constructor property that references ______
the function that was used to create the object
let x = 10
function increase(x){ x++; } increase(x); console.log(x);//
10
let obj = {value: 10}
function increase(obj){ obj.value++; } increase(obj); console.log(obj.value);//
11
The method to get the keys of an object
Object.keys(object);
function Circle (radius, color){ this.radius = radius // this.color = color; }
HIDE COLOR FROM THE OUTSIDE
// let color = color;
What is temporal: SCOPE or CLOSURE?
scope
A getter is a ___?
a function that is used to read a property
Make the following falsy
if (value.x || value.y){ // code }
(!value.x || !value.y){
Another simple explanation for prototype explanation. A prototype is a __________
parent
Every object (except the root object) has a prototype (parent). To get the prototype of an object: //
Object.getPrototypeOf(obj);
Every object in Javascript has a prototype or parent except the _________
root object.
Objects created by a given constructor will have the same _______
prototype
________ created by a given constructor will have the same prototype
Objects
let person = {name: "steve'}; get prototype or person
object.getPrototypeOf(person);
to make an element of an object read only:
writeable: FALSE
The static method ____________ defines a new property directly on an object, or modifies an existing property on an object, and returns the object.
Object.defineProperty()
to make an element of an object not show up in object.key :
enumerable: FALSE
to ensure you can not delete a property of an object:
configureable: FALSE