+ 1
Can anyone tell me that the datatype "var" is only for integers or for other types too?
Can anyone tell me that the datatype "var" is only for integers or for other types too?
4 Respuestas
+ 3
for everything
var x = "string"; //string
var x = 12; //int
var x = 12.5;//float
var x = true;//boolean(true or false)
+ 2
Atul Panda It's for everything.
+ 2
var can be used to assign any data type and also you can change it in future
For example
var a = " Strong"
a = 4
a = 4.75
a = true
a = null
a = false
console.log(a) ;
Output :
false
You won't get any error
+ 2
Thank You