Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Last active July 29, 2018 06:46
Show Gist options
  • Save lotusirous/c694c38b0109da55eae5db9914f901aa to your computer and use it in GitHub Desktop.
Save lotusirous/c694c38b0109da55eae5db9914f901aa to your computer and use it in GitHub Desktop.
Delete an element in an array javascript
my_array = [
1,
2,
4,
5,
6,
]
function delete_at(array, index) {
tmp = array;
tmp.splice(index, 1);
return tmp;
}
console.log('before');
console.log(my_array);
console.log('after');
console.log(delete_at(my_array, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment