·  JavaScript – Syntax – Keywords – typeof

 

- Info:

  - typeof keyword returns the type of the specified variable.

 

- Example:

  - Create D\Temp\JavaScript\Test.html

 

    Test.html

    <script>

   

      //TYPEs OF VARIABLES.

      myNumber = 5;                             //number

      myFloat  = 5.5;                           //number

      myString = "text";                        //string

      myObject = {name:"John", age:25};         //object

      myArray  = ["one", 2];                    //object

   

      //DISPLAY TYPES.

      document.write(typeof(myNumber)+"<br>");  //number

      document.write(typeof(myFloat )+"<br>");  //number

      document.write(typeof(myString)+"<br>");  //string

      document.write(typeof(myObject)+"<br>");  //object

      document.write(typeof(myArray )+"<br>");  //object

      

    </script>