klass icon indicating copy to clipboard operation
klass copied to clipboard

Suggest a .constants() method like .statics() which defines values you cannot change.

Open bcowgill opened this issue 10 years ago • 1 comments

Consider this constructor:

'Thing': klass( function (name, fixed) { Object.defineProperty(this, 'CONST', { value: fixed, writable: false, enumerable: false, configurable: false }); this.gname = name; }).methods({ 'instMethod': function (param) { return this.CONST + ' ' + this.gname + ' ' + param; } }),

Would be cool if you could .constants({ 'CONST': fixed })

Either within the constructor ( to set the constant differently per instance ) or in the same place as the .methods() call to set constant values across all instances.

bcowgill avatar Feb 03 '15 20:02 bcowgill

this would be tough to implement since all values in JavaScript are not typed. :/

ded avatar Feb 03 '15 21:02 ded