0
the + operator some times it does nt add the numbers instead it concat those 2 numbers?
for example var a =2; var b=5; var result= a+b; document.write(result); o/p : 25
3 ответов
+ 7
It concatenates strings and adds numbers.
var a="2";
var b="3";
document.write(a+b);
Returns 23.
var a=2;
var b=3;
document.write(a+b);
Returns 5.
+ 1
JavaScript concatenates string and add numbers.
0
When you want to add, avoid single or double quotes when dealing with numbers else JavaScript will take them as strings. when that happens, you get concatenation instead of addition.