Are both addition and concatenation same in JavaScript?

HTMLJavascriptProgramming Scripts

Both addition and concatenation use the same + operator, but they are not same. Concatenation is used to concatenate i.e. add strings, whereas simple addition adds numbers.


Let us see an example showing adding numbers and adding strings. Both show different results −

<!DOCTYPE html>
         var val1 = 30 + "25";
         var val2 = 30 + 25;
Updated on 20-May-2020 09:08:53