-2

What is the Output of the following lines:

Kindly post your respective answers so that we all can get some clarity in depth.

console.log(1 +- "2" + "2");
console.log(1 +- "1" + "2");
console.log(+"1" + "1" + "2");
console.log("A"-"B"+"2");
console.log("A"-"B"+2);

Note:

The main purpose of asking this question here is:
Why 2 values (Undefined & some value) are printing when checking in console?

Can any one please solve my doubt?
Thanks inadvance.

Community
  • 1
  • 1

1 Answers1

-1

Every Statement returns undefined.

console.log(1 + "-2" + "2");  // undefined
console.log(1 +- "1" + "2"); // undefined 
console.log(+"1" + "1" + "2"); // undefined 
console.log("A"-"B"+"2"); // undefined 
console.log("A"-"B"+2); // undefined
Lucas_Bo
  • 142
  • 1
  • 9
  • They **do** return `undefined`, but they also print something to the console. I believe the OP wanted to find out why those outputs were the way they were. – Amir Shabani May 08 '19 at 11:03