js patron prototipo/constructor
by Alejandro M
HTML
http://david.lampon.net/2015/06/11/patrones-de-diseno-en-javascript-2/
http://lurailabs.com/javascript-creacion-de-objetos-el-patron-prototype/
CSS
s
JavaScript
var Calculator = function (eq) {
//state goes here
this.eqCtl = eq ;// || 20
};
Calculator.prototype = {
add: function (x, y) {
this.eqCtl = x + y;
},
subtract: function (x, y) {
this.eqCtl = x - y;
}
};
var a = new Calculator(8);
document.write(a.eqCtl)
a.subtract(9,2);
document.write(a.eqCtl)
var b=new Calculator();
document.write(b.eqCtl)