What is the output of the following code: console.log(“5” + 5);?
a) “55”
b) 10
c) NaN
d) 5
Answer:
a) “55”
Explanation:
When you use the +
operator between a string and a number, JavaScript performs string concatenation. In this case, “5” (a string) is concatenated with 5 (a number), resulting in “55” (a string).
Example:
console.log("5" + 5); // Output: "55"
console.log(5 + 5); // Output: 10