4
var a = 2;

a.toString(); // "2"  Works 

2.20.toString(); // "2.2" Works

2..toString(); // "2" Also works  as '2.' is a valid float number 
a.toString(); // "2" Works

But

2.toString(); // Throw error

I am curious to know why javascript is working as it is working ?

intekhab
  • 1,566
  • 1
  • 13
  • 19
  • 6
    Similiar http://stackoverflow.com/questions/12272581/why-doesnt-javascript-let-you-call-methods-on-numbers-directly – Musa Sep 04 '15 at 12:29
  • OR http://stackoverflow.com/questions/9380077/why-cant-i-access-a-property-of-an-integer-with-a-single-dot – epascarello Sep 04 '15 at 12:33

0 Answers0