Use typeof to check the type of each array element - Javascript Data Type

Javascript examples for Data Type:typeof

Description

Use typeof to check the type of each array element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//  w w  w.  j av a 2s. c o  m
var someArray = ['Mike','Brett','Kim','Steve','0.1','0',{name:'Oliver'}];
for(var i = 0; i < someArray.length; i++){
  console.log(typeof someArray[i])
}
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials