开发者

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 ]");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜