简体   繁体   中英

Deleting an element from dictionary array in javascript

$scope.couponMatches = {};

I have a function which adds elements to a dictionary: $scope.couponMatches[$scope.currentMatch] = { firstElemet: "a", secondElement: "b" };

Every time I call this function it adds an elemet to my dictionary

EX: -MND3sdaDFFls2s : { firstElemet: "a", secondElement: "b" } -MGHuwenSN3mndb : { firstElemet: "a", secondElement: "b" }

In firebase I save it .

I need to delete one element with an index before save it to firebase.

You have a reserved word delete specially for this case.

Lets say you want to delete property a from object obj , use:

delete obj.a

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM