标签:style script asc title color tor logs 匿名 组合
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 <script> 7 function Person(name,sex) { 8 this.name = name || "匿名"; 9 this.sex = sex || "男"; 10 } 11 12 // 构造函数 - 学生 13 function Student(a,b,number) { 14 // 借用继承 15 Person.call(this,a,b); 16 this.number = number; 17 } 18 19 20 21 Person.prototype.sayHi = function () { 22 console.log("我是Person,我是男生"); 23 } 24 // 原型继承 25 Stuent.prototype = new Person(); 26 Student.prototype.constructor = Person; 27 28 var stu1 = new Student("小明","男","一号男主角"); 29 console.log(stu1); 30 stu1.sayHi(); 31 console.log(stu1.name); 32 </script> 33 </head> 34 <body> 35 36 </body> 37 </html>
标签:style script asc title color tor logs 匿名 组合
原文地址:http://www.cnblogs.com/mrszhou/p/7748659.html