Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  182] [ 4]  / answers: 1 / hits: 107839  / 11 Years ago, tue, march 12, 2013, 12:00:00

I have a function using an array value represented as



 markers[i]


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.


More From » arrays

 Answers
24

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.



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

cloneArray.splice(i,1);

console.log(cloneArray.join(---));

[#79645] Monday, March 11, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tiasavannahw

Total Points: 448
Total Questions: 122
Total Answers: 113

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
;