W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JSON 对象</h1> <p>如何删除 JSON 对象的属性。</p> <p id="demo"></p> <script> var myObj, i, x = ""; myObj = { "name":"Bill Gates", "age":62, "cars": { "car1":"Porsche", "car2":"BMW", "car3":"Volvo" } } delete myObj.cars.car3; for (i in myObj.cars) { x += myObj.cars[i] + "<br>"; } document.getElementById("demo").innerHTML = x; </script> </body> </html>