Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this array called... and how to remove items from it [duplicate]

I have an array that I am using, I am having difficulties describing what kind of an array it is, which is making it hard for me to work with it. So far it works for me. I am just curious.

I eventually want to remove the end of this array.

I tried .pop() and .grep(). Its not working.

Here is an example of my code.

var options = {}; $('.option:visible').each(function(){      var option_label = "";      var option_selected = [];      var option_img = "";       ...        options[option_label] = {          option_selected: option_selected,          option_image : option_img      }; }); 

What I am trying to do is:

if(option_label.indexOf("something") != -1) {    //then pop off options }  //continue about your business 

For clarification I wont know the exact title of the option_label.

like image 314
Aedonis Avatar asked Sep 19 '14 22:09

Aedonis


People also ask

How do you remove duplicates from an array?

We can remove duplicate element in an array by 2 ways: using temporary array or using separate index. To remove the duplicate element from array, the array must be in sorted order. If array is not sorted, you can sort it by calling Arrays. sort(arr) method.


1 Answers

It is a Javascript Object. You might want ot have a look at this question to remove properties, it gives different ways to to that. One of them is :

delete options.something; 
like image 154
Cyril Duchon-Doris Avatar answered Oct 26 '22 23:10

Cyril Duchon-Doris