Y
Hacker News
new
|
ask
|
show
|
jobs
by
Kilimanjaro
5585 days ago
Everyday you learn something new
Number.prototype.times=function(fn){ for(i=0;i<this;i++){ fn(i); } } 3..times(alert)
2 comments
zoul
5585 days ago
If somebody’s wondering about the double dot like me: “A common misconception is that number literals cannot be used as objects. That is because a flaw in JavaScript’s parser tries to parse the dot notation on a number as a floating point literal.”
link
atuladhar
5585 days ago
But then, "native prototypes should never be extended unless it is for the sake of compatibility with newer JavaScript features."
link