1//indexOf getting index of array element, returns -1 if not found
2var colors=["red","green","blue"];
3var pos=colors.indexOf("blue");//2
4
5//indexOf getting index of sub string, returns -1 if not found
6var str = "We got a poop cleanup on isle 4.";
7var strPos = str.indexOf("poop");//9
1a = [
2 {prop1:"abc",prop2:"qwe"},
3 {prop1:"bnmb",prop2:"yutu"},
4 {prop1:"zxvz",prop2:"qwrq"}
5];
6
7index = a.findIndex(x => x.prop2 ==="yutu");
8
9console.log(index);