angularjs - javascript does not accept 0 before any number -
this question has answer here:
- leading 0 in javascript 3 answers
var value = 05000; var addvalue = 1;
if calculate value + addvalue
, it's calculating wrong value
var result = value + addvalue;// it's return value 20481
see below image quick watch result
but if give value 5000( without 0 before value), it's calculate correct . why?
putting 0
before number makes octal number literal. interpreted in base 8.
for reason - not put leading zeros before numbers. doesn't intend.
if ran code in strict mode, you'd have gotten error instead:
uncaught syntaxerror: octal literals not allowed in strict mode.
Comments
Post a Comment