News for hackers. Stuff that matters.
Re:React and Redux are a joke right? by gr__or on Saturday August 19, 2017 @08:37AM (#15053032)
if you use ES2015:

  arr = [
    ...arr.slice(0, 2),
    'New Content',
    ...arr.slice(3)
  ]
Re:React and Redux are a joke right? by roselan on Saturday August 19, 2017 @09:04AM (#15053129)
In my eyes this slice of code is even worse than the array map one, where there is 2.5 pieces of logic (map, if, and 2 return that makes for the .5).

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.

Re:React and Redux are a joke right? by mwigdahl on Saturday August 19, 2017 @10:59AM (#15053728)
In ES2017 this gets substantially better:

const arr2 = Object.values({...arr, 3: 'New Content'});