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

This question already has an answer here:

  • How do I remove a property from a JavaScript object? 33 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;
    

    What is this array called…

    It's not an array at all. It's an object. An array is an ordered set of entries keyed by an index value (a number). An object (in JavaScript) is a set of unordered key/value pairs.

    ...and how to remove items from it

    To remove a property from an object, you use delete , specifying the property either with bracketed syntax and a string expression for the property name (which can be a variable reference, for instance to your option_label ):

    delete options[option_label];
    // or
    delete options["some property name"];
    // or
    delete options["some " + " property" + "name"];
    

    ...or with dot syntax and a literal property name:

    delete options.someLiteralPropertyName;
    

    .pop doesn't exist for objects, because objects have no order, so the concept of popping the "last" entry off of an object is meaningless.


    基本上是一个对象(或者你可以把它看作是一个关联数组),所以试试删除:

    delete  options[option_label];
    
    链接地址: http://www.djcxy.com/p/4674.html

    上一篇: 通过另一个对象内的键移除对象

    下一篇: 这个数组称为...以及如何从中删除项目