对象object在数组中的位置
2.1.8 、objIndexOf(object o)方法
功能:对象object在数组中的位置,
参数:object 形如{"name":"张三"}
返回值: int,表示元素在数组中的位置
示例:[
{"name":"张三","age":"18"},
{"name":"李四","age":"19"},
{"name":"王五","age":"20"},
{"name":"六六","age":"18"}
].objIndexOf({"name":"李四","age":"19"})
结果:1
尝试一下:
[
{"name":"张三","age":"18"},
{"name":"李四","age":"19"},
{"name":"王五","age":"20"},
{"name":"六六","age":"18"}
].objIndexOf({"name":"李四","age":"19"})
返回结果