Check if a variable is an array

Description

.isArray() checks whether an object is an array.

You can turn an array-like object to a true array using .makeArray().

By converting an array-like object to an array, you lose its methods and properties.

Example


<!DOCTYPE html> 
<html>
<head> 
    <script src="http://yourServer.com/jQuery/jquery.min.js"></script> 
    <script> 
        // clone  jQuery object
        var clonedjq =  $.extend(true, {}, $);
        //returns  "object"
        console.log($.type(clonedjq));
<!--   w w w.j  a v a2  s  .c o m-->
        // convert to JS  array
        var jqArray =  $.makeArray(clonedjq);

        // returns "array"
        console.log($.type(jqArray));
    </script> 
</head> 
<body> 
  <p>Your tags here</p>
</body> 
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Tutorial »




Basics
Selector
DOM
Event
Effect
Utilities