blarg blarg - 1 year ago 94
Javascript Question

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

I have a function using an array value represented as


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.

Answer Source

use array.splice method to get an array of elements excluding this one.

That affects the array permanently, if you do not want that, create a copy first.

var origArray = [0,1,2,3,4,5];
var cloneArray = origArray.slice();
var i = 3 ;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download