<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head><body><script type="text/javascript">//描述汽车
var car={//描述属性
color:'red',//描述方法
run:function(){
document.write("The car is running!");}}//获取属性
document.write(car.color);
document.write("<br>");
document.write(car['color']);
document.write("<br>");//执行方法
car.run();
car['run']();//当属性名用变量时使用[]
var key="color";
document.write(car[key]);
document.write("<br>");//修改
car.color='blue';
document.write(car['color']);
document.write("<br>");//循环访问对象里的内容for( var key in car ){//key为car的属性值
document.write(key,car[key]);}
document.write("<br>");//添加数据
car.price=10000;for( var key in car ){//key为car的属性值
document.write(key,car[key]);}
document.write("<br>");//删除数据
delete car.price;for( var key in car ){//key为car的属性值
document.write(key,car[key]);}</script></body></html>