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到最后一个函数的时候就删除不掉
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
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.