JavaScript prototype of function not working properly
I`ve made a prototype for "between" function. Why I 开发者_如何学编程can't use it directly on number? It is Number object whatsoever!
var a = 21;
21.between("( 16 20 ]"); // this is wrong and not working
//alert ( typeof 21 ) is number
a.between("( 16 20 ]"); // working
Try:
(21).between("( 16 20 ]");
When the parser (well, the lexer) sees "21." it thinks you've got a floating-point constant. What also works (and what really looks icky to me personally) is:
21..between("( 16 20 ]");
精彩评论