Hi i have a javascript code like this
var a=10;
var b="100";
document.write(b-a);
Actually it should show an error when we are subtracting a number from a string but it is showing as 90 as output but when we do b+a it is showing 10010 as output what is this behaviour.
When you subtract, Javascript attempts to cast the String
bto Number, because there is no-operation defined for String.When you use the
+sign, Javascript attempts to cast the Numberato a String, because+is defined as concatenation for a String.