Object.defineProperty(o, n, { get: function() { this[n] = {}; } }) this works in Firefox, and not in Chrome...
-
-
Replying to @seanmonstar
@seanmonstar what are you expecting to happen? You're not returning anything from your get...see?1 reply 0 retweets 0 likes -
Replying to @csuwildcat
@csuwildcat i forgot the `return this[n] = {}`. I'm hoping the property will be set to a plain object, but I don't know which acts correctly2 replies 0 retweets 0 likes -
Replying to @seanmonstar
@csuwildcat specifically, I'm defining a getter on a prototype, to hopefully lazy-create an object on an instance when/if it's needed.1 reply 0 retweets 0 likes -
Replying to @seanmonstar
@seanmonstar so inside your getter, do a create of a new object and stick it on the instance by redefining the proto via 'value'.1 reply 0 retweets 0 likes -
Replying to @csuwildcat
@csuwildcat yea, that works in both engines, but defineProperty is *SLOW*. Object creation gets faster, property access is far slower1 reply 0 retweets 0 likes -
Replying to @seanmonstar
@seanmonstar or do: return this.__props__[n] ? this.__props__[n] : this.__props__[n] = {}; Assuming you're not against creating a props obj.2 replies 0 retweets 0 likes
@csuwildcat the extra lookup and `if` are slower than i want. I'm just curious which engine has it wrong with my example.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.