+ 1
What will be output?
alert('Sign Up'); document.write("Hello") ; var x = "5" ; document.write(x++); Pls tell me output of this I want output to be first display alert sign up the show Hello and then no. 6 will be printed. If there was mistake pls tell me https://webknowledgepedia.wordpress.com/
5 Respuestas
+ 2
Ananaya Jemberu So what should i change?
+ 2
Thnx it worked
+ 2
In javascript (var x = "5"; document.write(x++)) will not throw an error, "5" will be converted to the number 5, this is due to type conversion.
https://javascript.info/type-conversions
You should use prefix increment operator(++x) to get the results you are expecting, not postfix increment operator(x++).
https://javascript.info/operators#increment-decrement
https://code.sololearn.com/W1HGsJ52j3Di/#html
+ 1
Thnx ODLNT
+ 1
Knowledge Pedia You are welcome. I'm glad I could help.