1

My code looks like this. At the beginning I have defined nested arrays

var license= [{ 
    packet: [{
        pay: [],
        channel: [],
        fun: []
    }] 
}];

Add item work corect

function addPayChannelToObject(name) {

    var paychannel = { name: name };
    license[0].packet[0].pay.push(paychannel);

    console.log(pay);
}

How can I delete an item by value?

function removeItemFromObject(name) {

    //??
    console.log(pay);
}
Tolga Evcimen
  • 6,438
  • 10
  • 52
  • 82
Tihomir Budic
  • 309
  • 5
  • 11
  • You seem to know how to access the *nested* array, and the remaining question "delete an item by value" is a plain duplicate. – Bergi Jun 26 '14 at 12:54

1 Answers1

0

Try this way

 function removeItemFromObject(name) {

     var index = license[0].packet[0].pay.indexOf(name); // found index of value
     if(index > -1){
       license[0].packet[0].pay.splice(index, 1); //remove index
     }
     console.log(pay);
   }
Girish
  • 11,254
  • 3
  • 32
  • 48