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