Skip to content
Advertisement

How to select all other values in an array except the ith element?

I have a function using an array value represented as

JavaScript

How can I select all other values in an array except this one?

The purpose of this is to reset all other Google Maps images to their original state but highlight a new one by changing the image.

Advertisement

Answer

Use Array​.prototype​.splice to get an array of elements excluding this one.

This affects the array permanently, so if you don’t want that, create a copy first.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement