if you use ES2015:
arr = [
...arr.slice(0, 2),
'New Content',
...arr.slice(3)
] arr = [
...arr.slice(0, 2),
'New Content',
...arr.slice(3)
]In the version you have 2 spread operators, an array construct and 3 hardcoded ints.
I might not use the correct academic terms, and I might not be yet fully accustomed to es2015, but this way of writing stuff always make me pause and double check the code.
const arr2 = Object.values({...arr, 3: 'New Content'});