如何从JavaScript对象中删除属性?
要从JavaScript对象中删除属性,请使用delete关键字。您可以尝试运行以下代码以了解如何删除属性
示例
<!DOCTYPE html><html>
<body>
<p id="demo"></p>
<script>
var cricketer = {
name:"Amit",
rank:1,
points: 150
};
delete cricketer.rank;
document.getElementById("demo").innerHTML =
cricketer.name + " has " + cricketer.rank + " rank.";
</script>
</body>
</html>
以上是 如何从JavaScript对象中删除属性? 的全部内容, 来源链接: utcz.com/z/331022.html