Compare Arrays to Object Properties in Javascript -
Compare Arrays to Object Properties in Javascript -
how compare array object w/ pairs of keys/values (properties:values) in javascript?
here how if arrays:
(var l = 0; l < vm.statesnotavailable.length; l++) { (var m = 0 ; m < vm.statesnotavailable.length; m++) { //maps values keys within vm.statesarray if (vm.statesnotavailable[l] == vm.stateswithcodes[m]) { delete vm.stateswithcodes.m; } } } this how if both objects:
(var key in object) { if (vm.statesnotavailable.hasownproperty(key)) { //now, object[key] current value if (vm.statesnotavailable[key] === vm.statesarray[key] ) delete object[key]; } } however, neither of these work me. so, how delete keys object intersect values within array, despite index (position)?
here solution:
//iterates through properties of object (var property in vm.stateswithcodes) { //iterates through indices of array (var m = 0 ; m < vm.statesnotavailable.length; m++) { //compares keys of object w/ values of array if (property == vm.statesnotavailable[m]) { //deletes property sequentially delete vm.stateswithcodes[property]; } } } javascript arrays object properties
Comments
Post a Comment