Reading Time: 2 minutes

So here is the part 2 of the strangeness of JavaScript. If you have missed out the part of one of strangeness of JavaScript click here

Many might have come from the .Net or Java or Ruby background. To those the below snippet might work strange to them

var a = 10; var b = 012; var c = a + b;//20

The reason why it is 20 because if you suffix number zero(0) then it would be considered as Octa (so here in this example 12 in Octa is equal to 10 so answer is 20)

So the lesson here is if you suffix zero before any decimal in JavaScript then it would be considered as Octa

typeof NaN;//number NaN==NaN//false typeof null;//object null instanceof object;//false (function(){ alert('hi'); })();//alerts 'hi' //Strange part here is a function can execute themselves var numA = 9999999999999999; numA;//10000000000000000 true === 1//false (this is you are already aware) true + true === 2 //true (so true + true is 2) true - true === 0 //true (so true - true is 0) var arrayMap = [1]; arrayMap['first'] = 'first value'; arrayMap['second'] = 'second value'; arrayMap.length;//1 arrayMap['first'];//first value arrayMap['second'];//second value