Object.defineProperty(Number.prototype, 'foo', { get: function () { var me = this return function () { return me.valueOf() } } }) console.log(5..foo())
These are 5 logs in Chrome, but 0 in Firefox.
Object.defineProperty(Number.prototype, 'bar', { get: function () { return this.valueOf() } }) console.log(5..bar)
These are 5 logs in both browsers as expected.
Can someone explain this behavior and perhaps suggest how the first example can be rewritten to work in Firefox, like in Chrome?
jsfiddle.net/V2sHg/2/
source share