class instance interface abstract-class extends implements private protected public static const constructor super read-only friendly-method event |
ConstDeclaring a constant property is very easy. You just need to add "CONST" declaration. A constant cannot be set after the "init" function run. var Person=Class({
init:function(name){
//const property can be set inside a constructor
this._name=name;
},
setJob:function(job, hrs){
if(hrs > this._MAX_WK_HRS) return false;
this._job=job;
return true;
},
_MAX_WK_HRS:CONST(8), //declare a constant attribute
_job:false,
_name:CONST(true) //declare a constant attribute
});
|