const x = 8;
const y = 4;
const result = x + y;
console.log(result);
Output
12
const x = '8';
const y = 4;
const result = x + y;
console.log(result);
Output
84
const x = '8';
const y = 4;
const result = x + y;
console.log(result);
console.log(typeof(result));
Output
84
string
const x = 'hello';
const y = 4;
const result = x + y;
console.log(result);
Output
hello4
const result1 = '5' - '2';
const result2 = '5' - 2;
const result3 = '5' * 2;
const result4 = '5' / 2;
console.log(result1);
console.log(result2);
console.log(result3);
console.log(result4);
Output
3
3
10
2.5
const result1 = '5' - '2';
const result2 = '5' - 2;
const result3 = '5' * 2;
const result4 = '5' / 2;
console.log(result1);
console.log(result2);
console.log(result3);
console.log(result4);
console.log(typeof(result1));
console.log(typeof(result2));
console.log(typeof(result3));
console.log(typeof(result4));
Output
3
3
10
2.5
number
number
number
number
const result = '4' - 'hello';
console.log(result);
Output
NaN
const result1 = '4' - true;
console.log(result1);
const result2 = '4' + true;
console.log(result2);
const result3 = 4 + false;
console.log(result3);
Output
3
4true
4
const result = Number('324');
console.log(result);
console.log(typeof(result));
Output
324
number
const result = Number(true);
console.log(result);
console.log(typeof(result));
Output
1
number
const result = String(257);
console.log(result);
console.log(typeof(result));
Output
257
string
const result1 = String(true);
console.log(result1);
console.log(typeof(result1));
const result2 = String(false);
console.log(result2);
console.log(typeof(result2));
Output
true
string
false
string
const result = (257).toString();
console.log(result);
console.log(typeof(result));
Output
257
string
Q. What is the output of the following code?
console.log('5' - 3);
- 2
- 53
- Error
- NaN
Answer: 1