Rajeev Kumar
What is the output of the Following JavaScript statement?

console.log(1 + “2” + “2”);
console.log(1 + “2” + 2);
console.log(1 + 2 + “2”);
console.log(“1” + “2” + 2);
console.log(1 + 2 + “2”);
console.log(“1” + “2” + “2”);
console.log(1 + 2 + 2); **

By Rajeev Kumar in .NET on Feb 21 2023
  • Tuhin Paul
    Feb, 2023 22

    The output of the following JavaScript statements will be:

    “122”
    “122”
    “32”
    “122”
    “32”
    “122”
    5

    Explanation:

    1. In the first statement, the addition operator is used to concatenate the string “1” with the string “2” twice. So, the output will be “122”.

    2. In the second statement, the string “1” is concatenated with the string “2” and then the number 2 is added to the resulting string. So, the output will be “122”.

    3. In the third statement, the numbers 1 and 2 are added together to make 3 and then the string “2” is concatenated to the resulting number. So, the output will be “32”.

    4. In the fourth statement, the string “1” is concatenated with the string “2” twice, and then the number 2 is added to the resulting string. So, the output will be “122”.

    5. In the fifth statement, the numbers 1 and 2 are added together to make 3 and then the string “2” is concatenated to the resulting number. So, the output will be “32”.

    6. In the sixth statement, the string “1” is concatenated with the string “2” twice. So, the output will be “122”.

    7. In the seventh statement, the numbers 1 and 2 are added together to make 3 and then the number 2 is added to the resulting number. So, the output will be 5.

    • 1


Most Popular Job Functions


MOST LIKED QUESTIONS