JavaScript function prototype not working properly

I made a prototype for the function between . "Why can't I use it directly by number? This is a Number object in general!

var a = 21;
21.between("( 16 20 ]"); // this is wrong and not working
//alert ( typeof 21 ) is number
a.between("( 16 20 ]");  // working
+3
source share
1 answer

Try:

(21).between("( 16 20 ]");

When the parser (well, lexer) sees "21." he thinks you have a floating point constant. What also works (and what actually looks disgusting to me personally):

21..between("( 16 20 ]");
+6
source

All Articles