私はこのような配列を持っています:
[{prop1:"abc",prop2:"qwe"},{prop1:"bnmb",prop2:"yutu"},{prop1:"zxvz",prop2:"qwrq"},...]
配列全体を反復せずに、条件に一致するオブジェクトのインデックスを取得するにはどうすればよいですか?
たとえば、 が与えられた場合、prop2=="yutu"
index を取得したいとします1
。
見まし.indexOf()
たが、のような単純な配列に使用されていると思います["a1","a2",...]
。私もチェック$.grep()
しましたが、これはインデックスではなくオブジェクトを返します。