jquery InArray () function detailed

Source: Internet
Author: User

jquery inarray () function detailed

Jquery.inarray (Value,array)
Determines the position of the first parameter in the array (returns 1 if not found).


Determine the index of the ' the ' the ' the ' the ' parameter in ' array ( -1 if not found).
return value
Jquery

Parameters
Value (Any): used to find in an array whether there is a

Array: Arrays to be processed.


Today, a friend asked a question as follows

var testarr=[{"A": "0"},{"B": "1"},{"C": "2"}];alert ($.inarray ({"A": "0"},testarr));

  
Say this value always returns-1;

At first glance, I didn't notice, so I wrote a paragraph for him.


var obj={' m ': ' 1 '};var arr=[obj, ' 1 ', 2];alert ($.inarray (Obj,arr));

This return value is normal.

It was later realized that the object was the reference type.

The attributes of a reference type can be demonstrated in a short program

var obj={"A": 0};var obj1={"a": 0};
alert (obj==obj1);//false;---------------------
var obj={"a": 0};
var obj1=obj;
alert (OBJ==OBJ1);
True

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.