creating an object
2 ways
Object constructor4
What is it?
Object constructor
Syntax
Syntax
var a = Object(val)
3 situations
__proto__8
[[Prototype]]
prototype
someFunc.prototype // empty object
someFunc.prototype.prop = ‘eggs’
someFunc.prototype.method = function() {}
*You add methods (or attributes) as you see fit
constructor property<span>5</span>
Object.prototype
Array constructor
Changing Prototype Manually
2 Options
Class/Instance Patterns
in JavaScript
5 most common are:
Note: The use of Object.create is sometimes called “Prototypal Inheretance” but this probably more accurarely described as “Prototypal Instantiation” since it’s less about creating a child class from a parent class, and more about creating a new object based off of another object (that we treat as a class)
Inheritance
JavaScript
5 approaches
Psuedo-classical Instantiation
What is it?
Syntax
}
Person.prototype.method1 = functioin( ) { }
var dude = new Person()
Psuedo-classical Instantiation
Steps
Steps
ES6 Classes
2 approaches
Consists of
ES6 Classes
constructor function
ES6 Classes
static method
Factory Pattern
Steps
Prototypal Pattern
newObj.prop1 = ‘hello’
newObj.method1 = someFunc
Steps
Psuedoclassical Inheritance
Steps
polyfill
Module Pattern
Steps
Singleton Pattern
idempotence
*