Jquery method to determine whether it is an array: Use the isArray method to determine whether a variable is an array type. The return value is a Boolean type, and the code is [var bool1 = $.isArray(obj)].
Recommendation: "jquery video tutorial"
Jquery method to determine whether it is an array:
jquery provides the isArray
method to determine whether a variable is an array type, and the return value is Boolean type.
Example:
var obj = {a:1}; var arr = [1, 2]; var bool1 = $.isArray(obj); var bool2 = $.isArray(arr); console.log(bool1); //false console.log(bool2); //true
Native js method to determine whether it is an array:
[] instanceof Array // true [].constructor == Array // true Object.prototype.toString.call([]) == '[object Array]' // true
Related free learning recommendations: JavaScript (video)
The above is the detailed content of How jquery determines whether it is an array. For more information, please follow other related articles on the PHP Chinese website!