lundi 25 février 2013

Javascript objects

JS does objects, but kind of weirdly...

A JS object class : it starts of as a function which is the constructor

function AcdBAPI() {
}

Add a STATIC method:
AcdBAPI.mystaticmethod = function(param1) {
}

An INSTANCE method
AcdBAPI.prototype.mymethod = function(param2) {
  this._myp = param2;
}

Instance variables : just referenced as this.varname

Aucun commentaire: