Skip to content

Instantly share code, notes, and snippets.

@keyserfaty
Created August 18, 2016 19:50
Show Gist options
  • Save keyserfaty/6d5bd79059eaa01eadbe721b833c6e24 to your computer and use it in GitHub Desktop.
Save keyserfaty/6d5bd79059eaa01eadbe721b833c6e24 to your computer and use it in GitHub Desktop.
Remove element from array without mutation
const index = endpoints.indexOf(action.payload.endpointName);
return endpoint.name === action.payload.endpointName
? endpoints
.slice(0, index)
.concat([endpoints[index] + 1])
.concat(endpoints.slice(index + 1))
: [...endpoints, endpoint];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment