Created
December 11, 2014 07:56
-
-
Save zamnuts/906885302fb288bd3629 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var C = function C(a,b) { | |
this.a = a||''; | |
this.b = b||''; | |
}; | |
Object.defineProperties(C.prototype,{ | |
a: { | |
configurable: true, | |
enumerable: true, | |
get: function() { | |
return this._a; | |
}, | |
set: function(v) { | |
if ( typeof v === 'undefined' || v === null ) { | |
v = ''; | |
} | |
v += ''; | |
this._a = v.toLowerCase(); | |
} | |
}, | |
_a: { | |
configurable: false, | |
enumerable: false, | |
writable: true, | |
value: '' | |
}, | |
b: { | |
configurable: true, | |
enumerable: true, | |
writable: true, | |
value: '' | |
} | |
}); | |
var c = new C('HELLO','WORLD'); | |
console.log('c instance object: ',c); | |
console.log('c._a enumerable? %s',c._a.propertyIsEnumerable()); | |
console.log('c as stringified JSON: %s',JSON.stringify(c)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment