Js is a function method used to detect class array objects, js Array

Source: Internet
Author: User

Js is a function method used to detect class array objects, js Array

As follows:

// Determine whether o is a class array object // strings and functions have the length attribute, But they // can be excluded by typeof detection. In the JavaScript client, DOM text nodes // also have the length attribute. You need to use the extra judgment o. nodeType! = 3 exclude function isArrayLike (o) {if (o & // o non-null/undefined and other typeof o === "object" & // o is the object isFinite (o. length) & // o. length is a finite value o. length> = 0 & // and non-negative o. length = Math. floor (o. length) & // and is an integer o. length <4294967296) {// and less than 2 ^ 32 return true; // then o is a class array object} else {return false; // otherwise not }}

Array object: an object with a length attribute and a non-negative integer attribute, such as an arguments object and an object returned by some DOM methods.

The above js function method used to detect class array objects is all the content shared by the editor. I hope to give you a reference, and I hope you can also support the help house.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.