[image] Roket: Yes, almost everything is true. Only I need an array (“property_order”) of type: That part should be relatively easy to achieve, just change the structure of the object that’s being pushed to the property_order array. So replace item.property_order.push({ [keys[i]]: i }); … Answer from MutedJam on community.n8n.io
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › findIndex
Array.prototype.findIndex() - JavaScript | MDN
July 20, 2025 - The findIndex() method of Array instances returns the index of the first element in an array that satisfies the provided testing function. If no elements satisfy the testing function, -1 is returned.
Discussions

is there a way to use .indexOf to find an object's value in an array?
Elizabeth Chai is having issues with: for example, var things More on teamtreehouse.com
🌐 teamtreehouse.com
2
December 31, 2017
How to get indexOf() from an id that's inside an object that's inside an array? I have provided an example.
Array.prototype.findIndex takes a function as its argument. That's right, functions themselves can be passed into functions! First, we can define a function that returns true if the uniqueId is 2 and false otherwise. function uniqueIdIsTwo(user) { return user.uniqueId === 2 } Then we can pass that function as the parameter of findIndex const index = myArray.findIndex(uniqueIdIsTwo) Notice how we're passing the function itself, we're not calling it! findIndex takes care of calling our function. In fact, findIndex calls our function for every element of the array and comes back with the index when our function returns true (or returns the magical -1 if our function never returns true). It's annoying to define a separate function each time, so we can also use an anonymous function instead. Anonymous means it doesn't have a name. Naming things is hard, so this is a useful thing to avoid naming it! const index = myArray.findIndex(function(user) { return user.uniqueId === 2}) Finally, we can also use arrow functions, which are a little more concise. There are differences between arrow functions and "regular" functions that are important to learn (some other time) but they are not different for this particular case. const index = myArray.findIndex(user => user.uniqueId === 2) More on reddit.com
🌐 r/learnjavascript
30
31
November 3, 2021
Get index of object in array
How can I get the index of an obj in an array of objects? const arr = [ {x: "a", y: 1}, {x: "b", y: 2} ] const i = arr.indexOf({x: "a", y: 1}) console.log(i) // output: -1 I would expect the output to be 0, but it’s telling me the object does not exist. More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
August 29, 2018
How to find an object in an array using indexOf() ?
It would work if you had a reference to the original object const orig = {x:0,y:0} let lis = [orig,{x:20,y:0}] console.log(lis.indexOf(orig)) // 0 or let lis = [{x:0,y:0},{x:20,y:0}] const orig = lis[0] console.log(lis.indexOf(orig)) // 0 But there is no built-in compare-by-value for objects in JavaScript. If you're not comparing references to the same object, they won't match, even if they have the same values. You would need to create your own comparison function or use one from a library like lodash . Then you can use that with findIndex. let lis = [{x:0,y:0},{x:20,y:0}] console.log(lis.findIndex(el => isEqual(el, {x:0,y:0}))) // 0 More on reddit.com
🌐 r/learnjavascript
3
2
December 20, 2019
🌐
Sololearn
sololearn.com › en › Discuss › 2339895 › how-to-get-index-number-of-object-array-using-indexof-method-only-in-javascript
How to get index number of object array using indexOf method only in JavaScript? | Sololearn: Learn to code for FREE!
for(i of arr){ console.log(arr.indexOf(i)); } 10th Jun 2020, 4:32 PM · Abhay · + 2 · Thanks Abhay and thanks to infinite too · 10th Jun 2020, 4:59 PM · Dhruti · + 1 · I did this way but I want to do it for this array given below: var arr = [ {id : 1, value : 'a'}, {id : 2, value : 'b'} ] ; 10th Jun 2020, 4:20 PM ·
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › indexOf
Array.prototype.indexOf() - JavaScript | MDN
const beasts = ["ant", "bison", "camel", "duck", "bison"]; console.log(beasts.indexOf("bison")); // Expected output: 1 // Start from index 2 console.log(beasts.indexOf("bison", 2)); // Expected output: 4 console.log(beasts.indexOf("giraffe")); // Expected output: -1 ... Element to locate in the array. ... Zero-based index at which to start searching, converted to an integer. Negative index counts back from the end of the array — if -array.length <= fromIndex < 0, fromIndex + array.length is used.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-program-to-find-index-of-an-object-by-key-and-value-in-an-array
JavaScript Program to Find Index of an Object by Key and Value in an Array - GeeksforGeeks
July 23, 2025 - This method iterates over the array elements and uses Object.entries() to get an array of key-value pairs from the object. We then check if the object contains the specified key and if its value matches the given value. Example: In this example, we will find the index of an object by key and value in a JavaScript array using the for...of loop and Object.entries().
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-indexof-method-in-an-object-array
JavaScript indexOf() method in an Object Array - GeeksforGeeks
March 14, 2024 - JavaScript · let fruits = [ { name: 'apple', color: 'red' }, { name: 'banana', color: 'yellow' }, { name: 'orange', color: 'orange' } ]; // Find the index of an object in the array let index = fruits.indexOf({ name: 'banana', color: 'yellow' }); console.log(index); // Output: -1 (Not found) Output ·
🌐
Reddit
reddit.com › r/learnjavascript › how to get indexof() from an id that's inside an object that's inside an array? i have provided an example.
r/learnjavascript on Reddit: How to get indexOf() from an id that's inside an object that's inside an array? I have provided an example.
November 3, 2021 -

Hi everyone, I have been stuck on this for about 10 hours now....

Let me post the code, then explain exactly what I need to do.

Here's my array:
myArray[obj, obj, obj];

Here's my objects that are inside the array:
obj {name : "keith", uniqueId : 0}
obj {name : "keith", uniqueId : 1}
obj {name : "keith", uniqueId : 2}

Here's what I need to do:

I need to get the indexOf() these objects based on that uniqueId. The objects will be moved around the array and could be in any position.

myArray[obj, obj, obj];
obj {name : "keith", uniqueId : 0} //myArray index 2
obj {name : "keith", uniqueId : 1} //myArray index 0
obj {name : "keith", uniqueId : 2} //myArray index 1

So how do I do this? I'd like to do something like:
indexOf(object with the unique id of 2) // 1

🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Indexed_collections
Indexed collections - JavaScript | MDN
The indexOf() method searches the array for searchElement and returns the index of the first match.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-standard-objects-arrays
JavaScript Standard Objects: Arrays
January 26, 2020 - If the element is not in the array, indexOf returns -1. ... fromIndex (Optional): The index at which you want to start the search at. If the fromIndex is greater than or equal to the array’s length, the array is not searched and the method returns -1. If the fromIndex is a negative number, it considered an offset from the end of the array (the array is still searched forwards from there).
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-get-the-index-of-an-object-by-its-property
JavaScript Get the index of an object by its property - GeeksforGeeks
October 14, 2025 - let arrayObj = [{ prop_1: 'val', prop_2: 'val_12', prop_3: 'val_13' }, { prop_1: 'val', prop_2: 'val_22', prop_3: 'val_23' }]; function findIndexInArray() { let prop = 'prop_2'; let val = 'val_22'; console.log("Index of prop = " + prop + " val = " + val + " is = " + arrayObj.map(function (e) { return e.prop_2; }).indexOf(val)); } findIndexInArray(); Output · Index of prop = prop_2 val = val_22 is = 1 · Syntax: array.map(function(currentValue, index, arr), thisValue) Using for loop we can iterate over the array of objects and check the given value of prop matches or not. JavaScript ·
🌐
W3Schools
w3schools.com › jsref › jsref_indexof_array.asp
JavaScript Array indexOf() Method
The indexOf() method starts at a specified index and searches from left to right (from the given start postion to the end of the array).
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › array.prototype.indexof()
JavaScript Array indexOf() Method
November 6, 2024 - To locate an object in an array ... { guestIndex: 0 }Code language: JavaScript (javascript) Use the JavaScript array indexOf() method to locate an element in the array....
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Get index of object in array - JavaScript - The freeCodeCamp Forum
August 29, 2018 - How can I get the index of an obj in an array of objects? const arr = [ {x: "a", y: 1}, {x: "b", y: 2} ] const i = arr.indexOf({x: "a", y: 1}) console.log(i) // output: -1 I would expect the output to be 0, but it’s t…
🌐
Mimo
mimo.org › glossary › javascript › array-indexof-method
JavaScript Array indexOf() method: Syntax, Usage, and Examples
The indexOf() method lets you search an array for a specific value and returns its first index. If the value isn’t found, it returns -1. The JavaScript array indexOf method is a quick and reliable way to determine the position of an element in an array, especially when working with primitive ...
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript array indexof method
JavaScript Array indexOf Method Explained
September 1, 2008 - The JavaScript Array indexOf() method is used to return the first occurrence index of a specified element within an array (if it is present at least once).
🌐
Medium
medium.com › @gautamshekhar078 › javascript-indexof-array-method-b340a97c29b6
JavaScript IndexOf() Array Method | by Gautamshekhar | Medium
November 25, 2024 - const sentence = 'The quick brown fox jumps over the lazy dog'; const index = sentence.indexOf('fox'); console.log(index); // 16
🌐
Medium
medium.com › @navyjot › javascript-indexof-and-findindex-in-array-bc611eccf0d8
Javascript : IndexOf and FindIndex in Array. | by Navjot | Medium
May 23, 2020 - So i took to array one simple array and another array of objects, and i ran both of these commands on them ... So my verdict is that the best case scenario is that we should use indexOf for simple array and findIndex on on array of objects.
🌐
ServiceNow Community
servicenow.com › community › developer-forum › get-index-of-javascript-object-with-array › m-p › 1505211
Solved: get index of Javascript object with Array - ServiceNow Community
August 5, 2017 - From the title, i see you are looking for getting the index of an array in Javascript object( based on a value)? Please correct me if I am wrong. If thats the case, you can use 'map' function. Also, I think the inc2 one line # 1 is typo, I corrected it. var inc1 = { num: 'INC111', sd: 'email' }; var inc2 = { num: 'INC222', foo: 'internet' } var arr = []; arr.push(inc2,inc1); pos = arr.map(function(input) { return input.num; }).indexOf('INC111'); gs.log(pos); Hope this helps.