Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TestClass (name) {
- this.name = name;
- this._somevalue = "this._somevalue";
- this._read = 0;
- }
- Object.defineProperty(TestClass.prototype, 'somevalue', {
- 'get': function () {
- console.log(++this._read);
- return this._somevalue;
- },
- 'set': function (value) {
- console.log(this._somevalue);
- console.log(this.name);
- this._somevalue = value + 5;
- }
- });
- var obj = new TestClass("This is my name");
- obj.somevalue = 8;
- console.log(obj.somevalue);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement