You can use Object.assign
:
Object.assign([], array, {2: newItem});
More Related Contents:
- javascript extract certain properties from all objects in array
- Why are Objects not Iterable in JavaScript?
- Create object from array
- Filtering an array with a function that returns a promise
- How to generate range of numbers from 0 to n in ES2015 only?
- How to find duplicate values in a JavaScript array of objects, and output only unique values?
- Using Array objects as key for ES6 Map
- Convert ES6 Iterable to Array
- Get list of duplicate objects in an array of objects
- Extract certain properties from all objects in array
- spread operator vs array.concat()
- Unexpected comma using map()
- Find all values by specific key in a deep nested object
- Update one of the objects in array, in an immutable way
- Javascript: Is the length method efficient?
- How to create an array of objects from multiple arrays
- Array.from() vs spread syntax
- How to delete property from spread operator?
- Compare two Arrays with Objects and create new array with unmatched objects
- setState doesn’t update the state immediately
- Does ES6 introduce a well-defined order of enumeration for object properties?
- Why can I change a constant object in javascript
- ECMAScript 6 features available in Node.js 0.12
- ES6: Conditional & Dynamic Import Statements
- JavaScript ‘in’ operator for `undefined` elements in Arrays
- Can I use arrow function in constructor of a react component?
- javascript surprising array comparison
- How to destructure option argument with all default values in ES6?
- Is it possible to export Arrow functions in ES6/7?
- Group and count values in an array