For example:
Copy Code code as follows:
$.get (' Aaaaa.ashx ', null,function (d) {
Suppose D returns a value of 1,3,43,23,54,67
var arr = d.split (', ');
$.inarray (3,arr) ==-1//true
Why, Why?
If it's written like this
var arr = eval (' [' +d+ '] ');
$.inarray (3,arr) >-1//true
});
What is this for? Hope to know the friend posted back.
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
Copy Code code 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.
Copy Code code as follows:
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
Copy Code code as follows:
var obj={"a": 0};var obj1={"a": 0};
Alert (obj==obj1);/false;---------------------
var obj={"a": 0};
Var obj1=obj;
Alert (OBJ==OBJ1);
//true;