Updated on Kisan Patel
The typeof
operator returns the primitive type of the variable.
In the following script we have used typeof operator.
JavaScript[typeof.html]
<script type="text/javascript"> var Mystr = "Computer"; var Mynum = 100; var Myboolean = false; var Myobj; var Mynum1; //declared but not assigned any value var Myobj1; Myobj = new Date(); Myobj1 = null; //null is taken as object type document.write("Mynum = " + typeof(Mynum) + "<br/>"); document.write("Myboolean = " + typeof(Myboolean) + "<br/>"); document.write("Myobj = " + typeof(Myobj) + "<br/>"); document.write("Myobj1 = " + typeof(Myobj1) + "<br/>"); document.write("Mynum1 = " + typeof(Mynum1) + "<br/>"); document.write("Mystr = " + typeof(Mystr) + "<br/>"); </script>