@manhng

Welcome to my blog!

Javascript Prototype Pattern

July 14, 2017 08:13

Prototype Pattern:

http://scotch.io/amp/bar-talk/4-javascript-design-patterns-you-should-know/


var TeslaModelS = function() {
this.numWheels = 4;
this.manufacturer = 'Tesla';
this.make = 'Model S';
}

TeslaModelS.prototype = function() {

var go = function() {
// Rotate wheels
};

var stop = function() {
// Apply brake pads
};

return {
pressBrakePedal: stop,
pressGasPedal: go
}

}();

Categories

Recent posts