0
What is the output of this code? Why is it so?
var price = 55.55; document.write(price); price = "hell man"; var price; document.write(price)
1 Answer
+ 4
I assume you're using javascript. First of all it's not common to declear a variable twice. I would suggest to delete row no. 4: 'var price;' The result is the same anyway.
In other languages like java or c++ the data type of a variable is very static but in javascript the compiler asigns a new data type every time you asign a new value.
The output is simply the result of writing the first value and then the second:
Output: 55.55hell man