标签:
<!DOCTYPE html> <html> <head> <title>面向对象编程</title> <script type="text/javascript"> var person = {};//或者这样:var person = new Object(); person.name = "张三"; person.age = 20; //函数充当属性,属性变方法了! person.info = function() { alert(person.name); } person.info(); </script> <script type="text/javascript"> var people = { name: "李四", age: 30, info: function() { setTimeout("alert(people.name)",3000); } }; people.info(); </script> <script type="text/javascript"> function man(name,age) { this.姓名 = name; this.年龄 = age; this.个人信息 = function() { alert(this.姓名); } } var m1 = new man("王五", 32); m1.个人信息(); </script> </head> <body> </body> </html>
标签:
原文地址:http://blog.csdn.net/lucky51222/article/details/45604449