Javascript array retrieval extension and javascript Array Retrieval

Source: Internet
Author: User
Tags javascript array

Javascript array retrieval extension and javascript Array Retrieval

Paste the code first. Let's take a look

/** Method: easySelect (name, value) * function: simple search for an object * parameter: name is the field name, value field value (array) * return: A group of arrays, or an Array object */Array. prototype. easySelect = function (name, value) {var _ array = new Array (); for (var I = 0; I <this. length; I ++) {if (this [I] [name] = value) {_ array [_ array. length] = this [I] ;}} if (_ array. length = 1) {return _ array [0];} return _ array ;}

It is usually used for an array of imitation objects. Take the data of a field whose value is xx.

For example, we have an array with a name. We can use

Var _ array = xxxxxxxxxxxxxxxxxxx;

Var _ zhangsan = _ array. easySelect ("name", "Zhang San ");

If it is a class information data. Another class also has James. We can even use it like this:

Var _ zhangsan = _ array. easySelect ("name", "Zhang San"). easSelect ("classType", 1 );


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.