标签:ott class span demo name person log demo1 script
<script type="text/javascript"> function Person(name, age) { //构造函数 this.name = name; //只写属性 this.age = age; } Person.prototype.showName = function() { // 用的共同的父亲 alert("my name is " + this.name); } Person.prototype.showAge = function() { alert("my age is " + this.age); } var demo1 = new Person("李四", 15); var demo2 = new Person("李四", 15); var demo3 = new Person("张三", 15); demo1.showName(); alert(demo1.showName == demo2.showName); //true alert(demo1.showName == demo3.showName); //true </script>
标签:ott class span demo name person log demo1 script
原文地址:http://www.cnblogs.com/suxiaoxia/p/6679607.html