JavaScript remove item from nested Array -
JavaScript remove item from nested Array -
this question has reply here:
remove item array value 22 answersmy code looks this. @ origin 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 delete item value?
function removeitemfromobject(name) { //?? console.log(pay); }
try 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); } javascript
Comments
Post a Comment