Sunday 15 September 2013

Why does alert("1" - - "1"); produce 2 in javascript? -



Why does alert("1" - - "1"); produce 2 in javascript? -

when execute next javascript statement:

alert("1" - - "1");

i result 2.

why this?

since can't subtract strings, - operator converts them numbers. if subtract negative 1 positive 1 two.

javascript

No comments:

Post a Comment