Friday, 16 September 2016

javascript - What is this array called... and how to remove items from it




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.



Answer



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;

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...