var arr = [];
var len = oFullResponse.results.length;
for (var i = 0; i < len; i++) {
    arr.push({
        key: oFullResponse.results[i].label,
        sortable: true,
        resizeable: true
    });
}
Answer from RaYell on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript | MDN
July 28, 2026 - The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name, and has members for performing common array operations. In JavaScript, arrays aren't primitives but are instead Array objects with the following core ...
🌐
Reddit
reddit.com › r/javascript › array of objects, best way to do it.
r/javascript on Reddit: Array of objects, best way to do it.
November 9, 2018 -

So I made an array with objects. For example here, let's use people

    var people = [
        {
            id: 0,
    
            name: "John Doe",
    
            age: 47
        },
        {
            id: 1,
    
            name: "Jane Doe",
    
            age: 88
        },
        {
            id: 2,
    
            name: "Mason Louis",
    
            age: 17
        }
    ];

so now I can use people[1].name etc for accessing the data on each of these people. Someone just saw my code and said "That looks like total S**T".

What is the proper way to do this? I was thinking this way was fine, especially since it resembles JSON

EDIT: Would it be better to create a constructor and fill an array with instances?

Discussions

javascript - How to create an array of object literals in a loop? - Stack Overflow
In the same idea of Nick Riggs but I create a constructor, and a push a new object in the array by using it. More on stackoverflow.com
🌐 stackoverflow.com
What is the best way to create an array of objects in Javascript? - Stack Overflow
This would be an array of objects. More on stackoverflow.com
🌐 stackoverflow.com
Objects vs Arrays
Do you have one thing with multiple properties or do you have multiple things? The answer to this determines which you use. This is a good way to represent a dog (leaving Class aside) const dog = { name: 'Spot', age: 3, speak() { alert('woof'); } } This is a bad way to represent a dog const dog = [ 'Spot', 3, () => alert('woof'), ]; Why? console.log(dog.name); dog.speak(); Is much easier to understand than console.log(dog[0]); dog[2](); Besides just being hard to read, if your array ever goes out of order, all your code will break This is a good way to represent a list of dogs: const doggyDayCare = [ dog1, dog2, dog3, dog4, dog5, ]; This is a bad way to represent a list of dogs: const doggyDayCare = { dog1: dog1, dog2: dog2, dog3: dog3, dog4: dog4, dog5: dog5, } While you can do this, it's a lot harder to sort your dogs, find them, add to them, etc. Lets say I want all puppies const puppies = doggyDayCare.filter(dog => dog.age < 1); This gives me a new array of puppies. Could you do this with an object? Yes, but only by turning it into an array first, filtering down, then reducing back to an object. And it's ugly. const puppies = Object.entries(doggyDayCare) .filter(([key, dog]) => dog.age < 1) .reduce((previous, current) => { const result = { ...previous, }; result[current[0]] = current[1]; return result; }, {}); It is possible, but it is a bad idea. Adding a dog to an array is easy: doggyDayCare.push(newDog); How do you add a dog to an object? You have to make sure there already isn't a property with the same name for the given dog, or you'll replace it. You end up with another bit of ugly code to try to safely add a new property. So, if you have one thing with multiple properties, use an object, if you have multiple things, use an array. More on reddit.com
🌐 r/learnjavascript
29
8
March 10, 2023
Array inside a JavaScript Object? - Stack Overflow
I've tried looking to see if this is possible, but I can't find my answer. I'm trying to get the following to work: var defaults = { 'background-color': '#000', color: '#fff', weekdays: {['sun... More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › js › js_arrays.asp
JavaScript Arrays
In JavaScript, objects use named indexes. Arrays are a special kind of objects, with numbered indexes.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-array-of-objects-tutorial-how-to-create-update-and-loop-through-objects-using-js-array-methods
JavaScript Array of Objects Tutorial – How to Create, Update, and Loop Through Objects Using JS Array Methods
May 14, 2020 - Make sure to always add the case for zero when the compared value of both objects is the same to avoid unnecessary swaps. Array.every and Array.some come handy when we just need to check each object for a specific condition.
🌐
daily.dev
daily.dev › home › blog › webdev › create array of objects javascript: a beginner's guide
Create Array of Objects JavaScript: A Beginner's Guide | daily.dev
May 25, 2026 - Basics of JavaScript Objects: Objects are like containers with labeled info, making data easy to organize and access. Understanding Arrays: Arrays let you store a list of items, including objects, in a specific order.
🌐
Eloquent JavaScript
eloquentjavascript.net › 04_data.html
Data Structures: Objects and Arrays :: Eloquent JavaScript
Most values in JavaScript have properties, with the exceptions being null and undefined. Properties are accessed using value.prop or value["prop"]. Objects tend to use names for their properties and store more or less a fixed set of them. Arrays, on the other hand, usually contain varying amounts of conceptually identical values and use numbers (starting from 0) as the names of their properties.
Find elsewhere
🌐
YouTube
youtube.com › bro code
JavaScript ARRAYS of OBJECTS are easy! 🍎 - YouTube
00:00:00 array of objects00:01:29 access object properties00:02:19 push()00:02:59 pop()00:03:11 splice()00:03:28 forEach()00:04:08 map()00:05:18 filter()00:0
Published: November 21, 2023
Views: 20K
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-access-array-of-objects-in-javascript
How to Access Array of Objects in JavaScript ? - GeeksforGeeks
Using the brackets notation, you access objects in an array by specifying the array's name and the desired index. This method retrieves the entire object at the specified index. To access specific properties, combine it with dot notation for precision. ... Example: The code below demonstrates how we can use the brackets notation to access the elements of the array of objects.
Published: July 23, 2025
🌐
Reddit
reddit.com › r/learnjavascript › objects vs arrays
r/learnjavascript on Reddit: Objects vs Arrays
March 10, 2023 -

Hello! Just curious…do you guys like manipulating objects or arrays more? Pros and cons of both?

Personally I find dot notation with objects much much easier then iteration but I am a novice and I’m curious to know if my logic is flawed.

Thanks!

Top answer
1 of 5
33
Do you have one thing with multiple properties or do you have multiple things? The answer to this determines which you use. This is a good way to represent a dog (leaving Class aside) const dog = { name: 'Spot', age: 3, speak() { alert('woof'); } } This is a bad way to represent a dog const dog = [ 'Spot', 3, () => alert('woof'), ]; Why? console.log(dog.name); dog.speak(); Is much easier to understand than console.log(dog[0]); dog[2](); Besides just being hard to read, if your array ever goes out of order, all your code will break This is a good way to represent a list of dogs: const doggyDayCare = [ dog1, dog2, dog3, dog4, dog5, ]; This is a bad way to represent a list of dogs: const doggyDayCare = { dog1: dog1, dog2: dog2, dog3: dog3, dog4: dog4, dog5: dog5, } While you can do this, it's a lot harder to sort your dogs, find them, add to them, etc. Lets say I want all puppies const puppies = doggyDayCare.filter(dog => dog.age < 1); This gives me a new array of puppies. Could you do this with an object? Yes, but only by turning it into an array first, filtering down, then reducing back to an object. And it's ugly. const puppies = Object.entries(doggyDayCare) .filter(([key, dog]) => dog.age < 1) .reduce((previous, current) => { const result = { ...previous, }; result[current[0]] = current[1]; return result; }, {}); It is possible, but it is a bad idea. Adding a dog to an array is easy: doggyDayCare.push(newDog); How do you add a dog to an object? You have to make sure there already isn't a property with the same name for the given dog, or you'll replace it. You end up with another bit of ugly code to try to safely add a new property. So, if you have one thing with multiple properties, use an object, if you have multiple things, use an array.
2 of 5
5
when I need objects I use Object when I need an array I use Array. What is this question about? For a nail you need a hammer, for a screw you need... you get the idea...
🌐
Medium
medium.com › dailyjs › rewriting-javascript-converting-an-array-of-objects-to-an-object-ec579cafbfc7
Rewriting JavaScript: Converting an Array of Objects to an Object. | by Chris Burgin | DailyJS | Medium
April 23, 2017 - What we do in the snippet above is use reduce, which returns accumulator (obj), to which we append each item in the array using that items id. This will convert our array of objects into an object of objects. YAY! (If reduce is confusing you please please please go check them out here!
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object › values
Object.values() - JavaScript | MDN
const obj = { foo: "bar", baz: 42 }; console.log(Object.values(obj)); // ['bar', 42] // Array-like object const arrayLikeObj1 = { 0: "a", 1: "b", 2: "c" }; console.log(Object.values(arrayLikeObj1)); // ['a', 'b', 'c'] // Array-like object with random key ordering // When using numeric keys, the values are returned in the keys' numerical order const arrayLikeObj2 = { 100: "a", 2: "b", 7: "c" }; console.log(Object.values(arrayLikeObj2)); // ['b', 'c', 'a'] // getFoo is a non-enumerable property const myObj = Object.create( {}, { getFoo: { value() { return this.foo; }, }, }, ); myObj.foo = "bar"; console.log(Object.values(myObj)); // ['bar']
🌐
Medium
medium.com › @pahaniw › arrays-are-objects-7964f3c73280
Arrays are Objects. In JavaScript, arrays are indeed… | by Pahani Imandi | Medium
April 17, 2024 - Arrays are Objects In JavaScript, arrays are indeed objects, and as such, they inherit properties and methods from the Array.prototype object. This allows arrays to have built-in methods. One of the …
🌐
W3Schools
w3schools.com › js › js_objects.asp
JavaScript Objects
Getters and setters allow you to define Object Accessors (Computed Properties). ... Coding fundamentals as a game. Bite-sized lessons and challenges. ... Ready to start your journey? Your streak is waiting. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Arrays
An array is a special kind of object. The square brackets used to access a property arr[0] actually come from the object syntax. That’s essentially the same as obj[key], where arr is the object, while numbers are used as keys.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Indexed_collections
Indexed collections - JavaScript | MDN
2 weeks ago - This chapter introduces collections of data which are ordered by an index value. This includes arrays and array-like constructs such as Array objects and TypedArray objects.