Consider following code snippet:
 function a(value) { return true - value; } var b = a('4') + a('-4') + a(-'4') + a(4); console.log(b); 
What will be printed to the console?
Explanation
The ' - ' inside the function converts true and strings to a numbers. a('4') = -3; // 1-4 a('-4') = 5 // 1 - (-4) a(-'4') = 5 // 1 - (-4) a(4) = -3 // 1-4 console.log(-3+5+5-3) // 4

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback