Is a jq object an array or an object??
给我你的怀抱
给我你的怀抱 2017-06-12 09:28:41
0
3
1001

Many times it is said that the jq object is an array, but when tested with Object.prototype.toString.call(), it is found that it is [Object Object] instead of [Object Array], but the jq object we see on the console looks like It is arranged in the same way as an array, 0, 1... So, is the jq object an object or an array?

给我你的怀抱
给我你的怀抱

reply all(3)
代言

It is an object, but it looks like an array. We usually call this structure "array-like"

The key of this kind of object is the value [0, 1, 2, ...], and it has a length attribute, which is what it looks like below

selections = {
  0: dom1,
  1: dom2,
  length: 2
}
某草草

jQuery object, as the name suggests, is an object. It's just that it does have some features of arrays, such as being able to use subscripts, having a length attribute, etc., but it also has methods that have attributes that arrays don't have. This kind of object can be called an array-like object

曾经蜡笔没有小新

jQuery objects are objects

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!