InterviewHubPRO
Section Overview
Q167

Question 167 of 521

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

32%
JavaScript Internals (521 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

What would be the result of 1+2+'3'

The output is going to be 33. Since 1 and 2 are numeric values, the result of the first two digits is going to be a numeric value 3. The next digit is a string type value because of that the addition of numeric value 3 and string type value 3 is just going to be a concatenation value 33. Other operations like 3 * '3' do yield correct results because the string is coerced into a number.

Practical Code Example

javascript
// Evaluated from left to right:
// 1. 1 + 2 = 3 (numeric addition)
// 2. 3 + '3' = '33' (string concatenation coercion)
const result = 1 + 2 + '3';
console.log(result);         // '33'
console.log(typeof result);  // 'string'