Last active
July 29, 2018 06:46
-
-
Save lotusirous/c694c38b0109da55eae5db9914f901aa to your computer and use it in GitHub Desktop.
Delete an element in an array javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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