Skip to main content
improved code formatting
Source Link
rozsazoltan
  • 18.5k
  • 8
  • 50
  • 147

ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) =>  [   ...list.slice(0, index),   ...list.slice(index + 1)  ]; output = removeByIndex([33, 22, 11, 44], 1); //=> -> [33, 11, 44] console.log(output);

ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) =>  [   ...list.slice(0, index),   ...list.slice(index + 1)  ]; output = removeByIndex([33,22,11,44],1) //=> [33,11,44] console.log(output)

ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) => [ ...list.slice(0, index), ...list.slice(index + 1) ]; output = removeByIndex([33, 22, 11, 44], 1); // -> [33, 11, 44] console.log(output);

ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) => [ ...list.slice(0, index), ...list.slice(index + 1) ]; 

Then:

const removeByIndex = (list, index) => [ ...list.slice(0, index), ...list.slice(index + 1) ]; output = removeByIndex([33,22,11,44],1) //=> [33,11,44] console.log(output)
removeByIndex([33,22,11,44],1) //=> [33,11,44] 
 

ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) => [ ...list.slice(0, index), ...list.slice(index + 1) ]; 

Then:

removeByIndex([33,22,11,44],1) //=> [33,11,44] 

ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) => [ ...list.slice(0, index), ...list.slice(index + 1) ]; output = removeByIndex([33,22,11,44],1) //=> [33,11,44] console.log(output)
 

Improved formatting
Source Link
Adriano
  • 4k
  • 5
  • 36
  • 58

#ES6 & without mutation: (October 2016)ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) => [ ...list.slice(0, index), ...list.slice(index + 1) ]; 

Then  :

removeByIndex([33,22,11,44],1) //=> [33,11,44] 

#ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) => [ ...list.slice(0, index), ...list.slice(index + 1) ]; 

Then  :

removeByIndex([33,22,11,44],1) //=> [33,11,44] 

ES6 & without mutation: (October 2016)

const removeByIndex = (list, index) => [ ...list.slice(0, index), ...list.slice(index + 1) ]; 

Then:

removeByIndex([33,22,11,44],1) //=> [33,11,44] 
Source Link
Abdennour TOUMI
  • 94.6k
  • 42
  • 271
  • 274
Loading