What will be the output of the following code.

console.log(4 + "3");
console.log(4 - "3");

  1. ’43’, 1
  2. ‘7’, Error
  3. Error, Error
  4. None of the Above

Answer:

  1. ’43’ and 1

Explanation

  • 4 + ‘3’, here since we have one item as string, JavaScript will convert both of them as String, since string addition or concatination is possible.
  • 4 – ‘3’, here since we have one item as string, JavaScript will convert both to Int, since string subtraction is not a valid operation.