Check if input is an array with Array.isArray() - Javascript Array

Javascript examples for Array:isArray

Description

Check if input is an array with Array.isArray()

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(){// ww  w  . j  av  a 2s.  c  o  m
function draw(params) {
if (!Array.isArray(params)) return;
   var inner = '';
   params.map(function(param) {
       inner += param + '<br>';
   });
   document.body.innerHTML += inner;
}
draw(['hey', 'there']);

    }

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

Related Tutorials