javascript indexOf object value in array
// Get index of object with specific value in array const needle = 3; // needle const haystack = [{ id: 1 }, { id: 2 }, { id: 3 }]; // haystack const index = haystack.findIndex(item => item.id === needle);
javascript indexOf object value in array
// Get index of object with specific value in array const needle = 3; // needle const haystack = [{ id: 1 }, { id: 2 }, { id: 3 }]; // haystack const index = haystack.findIndex(item => item.id === needle);
using index of on array of objects
arr = [{x: "a", y: 1}, {x: "something", y: 2}] arr.findIndex(obj => obj.x === "a" && obj.y === 1);
javascript indexof
//indexOf getting index of array element, returns -1 if not found var colors=["red","green","blue"]; var pos=colors.indexOf("blue");//2 //indexOf getting index of sub string, returns -1 if not found var str = "We got a poop cleanup on isle 4."; var strPos = str.indexOf("poop");//9
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us