Home >Web Front-end >JS Tutorial >How does jquery determine whether it is an array?
Jquery method to determine whether it is an array: use the [$.isArray()] function, which can determine whether the specified parameter is an array, the syntax format is [$.isArray(object)]; if the parameter object is specified If it is an array, it returns true, otherwise it returns false.
Related recommendations: "jQuery Video Tutorial"
The operating environment of this tutorial: windows7 system, jquery3.2.1 version , this method is suitable for all brands of computers.
Jquery method to determine whether it is an array:
Use isArray() to determine whether it is an array
JQuery has encapsulated isArray() to determine whether it is an array
$.isArray()
The function is used to determine whether the specified parameter is an array; if the specified parameter is an array, it returns true, otherwise false is returned.
var arr = [1,3]; var bool = $.isArray(arr);//判断是否为数组 返回Boolean console.log(bool); //true
Supplement:js judgment method
instanceof judgment
var ary = [1,23,4]; console.log(ary instanceof Array); //true
Prototype chain method judgment
var ary = [1,23,4]; console.log(ary.__proto__.constructor==Array);//true console.log(ary.constructor==Array);//true 这两段代码是一样的
For more programming-related knowledge, please visit: Programming video course! !
The above is the detailed content of How does jquery determine whether it is an array?. For more information, please follow other related articles on the PHP Chinese website!