Y
Hacker News
new
|
ask
|
show
|
jobs
by
dclowd9901
4349 days ago
Really makes me wish you could invoke instance methods on numbers (ala 5.amIFive())
2 comments
Softcadbury
4349 days ago
You can :)
Number.prototype.amIFive = function(){ return this.valueOf() == 5; }
5..amIFive();
link
dclowd9901
4341 days ago
Ah, so you have to have two dots... I suppose the first one denotes the floating point value, and the second denotes the prototype accessor. Very clever.
link
phpnode
4349 days ago
(5).amIFive();
link
Number.prototype.amIFive = function(){ return this.valueOf() == 5; }
5..amIFive();