Last active
August 29, 2015 14:05
-
-
Save kicktheken/4c3ec28a878cb94bdfa5 to your computer and use it in GitHub Desktop.
runtime get vs. immediate get
This file contains hidden or 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
function Class() | |
{ | |
this._a = 0; | |
this._max = 0; | |
} | |
Object.defineProperty(Class.prototype, 'a', { | |
get: function() { return this._a; }, | |
set: function(v) { | |
if (v > this._max) { | |
v = this._max; | |
} | |
this._a = v; | |
return v; | |
} | |
}); | |
var c = new Class(); | |
c._max = 1000; | |
requestAnimationFrame(run); | |
function run(ts) { | |
console.log(c.a+=10,ts); | |
requestAnimationFrame(run); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment