What will be the result of the following code snippet?:
 var a = "1"; a = a + 0; a = a - 1; a = a + 1; alert(a); 
Explanation
Consider following explanation:

var a = "1"; // string
a = a + 0; //  "10" the + operator concatenate the strings
a = a - 1; // 9 the - operators convert string to a number
a = a + 1; // 10

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes