巴扎黑2017-04-10 15:51:34 0 1 198
javascript 的delete方法动态删除对象的时候,删除到最后一个为什么删除不掉?
var input_panelData = {
a:{},
b:{},
}
$("#remove_inputItemsPanel_" + i_item).click(function () {
var removename = $(this).data("removename");//获取子对象名字
delete input_panelData[removename];//删除此对象
$("#input_panel").empty();//清空p
inputItems();//重新获取对象并展示
console.log(removename);
})
但是delete到最后一个函数的时候就删除不掉
怪我咯 2017-04-10 15:53:341楼
The
delete
operator removes a property from an object.The correct usage as following:
delete
is only effective on an object's properties. It has no effect on variable or function names. Which means nothing will happen while deleting x variable. 赞 +0添加回复