Subtraction (-)

suggest change

The subtraction operator (-) subtracts numbers.

var a = 9; var b = 3; var c = a - b;

c will now be 6

If a string or boolean is provided in place of a number value, it gets converted to a number before the difference is calculated (0 for false, 1 for true):

"5" - 1;     // 4
7 - "3";     // 4
"5" - true;  // 4

If the string value cannot be converted into a Number, the result will be NaN:

"foo" - 1;      // NaN
100 - "bar";    // NaN

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents