Skip to content
Advertisement

Tag: arrays

How do I unset an element in an array in javascript?

How do I remove the key ‘bar’ from an array foo so that ‘bar’ won’t show up in Answer Don’t use delete as it won’t remove an element from an array it will only set it as undefined, which will then not be reflected correctly in the length of the array. If you know the key you should use splice

Advertisement