JS案例:通过字面量创建对象
来自CloudWiki
<!doctype html> <html> <head> <meta charset="utf-8"> <title>自定义对象案例测试</title> </head> <body> <script type="text/javascript"> var animal={ //通过字面量的方式创建新对象 name:"花花", owner:"王小丽", color:"黑色" } document.write(animal.owner+"家的小狗名字叫"+animal.name+",颜色是"+animal.color+"的"); </script> </body> </html>