Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
It's primitive numbers vs Number objects. Whenever you bind a primitive like 5 as the 'this' context of a function JavaScript has to turn it into a Number object because 'this' must always be an object.
-
The Number object evidently stays an object for normal operators. But the increment operator for some reason returns a number primitive. So the object's properties are lost. And you can't reassign them because a number primitive can't have properties.
-
This code is enough to show the problem:
function bool(){
return this? true: false;
}
alert(bool.call(false) === true)
Related Rants
Potato is not just a word.. 😎😎
undefined
js
javascript