【问题标题】:Deleting an element from dictionary array in javascript从javascript中的字典数组中删除元素
【发布时间】:2020-02-16 16:31:57
【问题描述】:

$scope.couponMatches = {};

我有一个向字典添加元素的函数: $scope.couponMatches[$scope.currentMatch] = { firstElemet: "a", secondElement: "b" };

每次我调用这个函数时,它都会在我的字典中添加一个元素

前: -MND3sdaDFFls2s:{firstElemet:“a”,secondElement:“b”} -MGHuwenSN3mndb : { firstElemet: "a", secondElement: "b" }

我在 firebase 中保存它。

我需要先删除一个带有索引的元素,然后再将其保存到 Firebase。

【问题讨论】:

    标签: javascript firebase dictionary


    【解决方案1】:

    您有一个专门用于这种情况的保留字delete

    假设您想从对象obj 中删除属性a,请使用:

    delete obj.a
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-26
      • 1970-01-01
      • 2021-04-09
      • 2015-12-30
      • 2016-05-06
      • 2011-08-16
      相关资源
      最近更新 更多