how to get the key of an obj from index in javascript code example Example: indexOf by object key var index = peoples.findIndex(p => p.attr1 == "john")