标签:优先级 xxx col div play 方法 技术 构造 原型
<script> function Person(){ } Person.prototype = { constructor: Person, name: ‘xxx‘, age: 22, sayName: function(){ console.log(this.name); } } var p = new Person(); p.sayName();//‘xxx‘ console.log(p.age);//22 </script>
<script> function Person(){ this.age = 233;//创建实例时赋给实例的属性 } Person.prototype = { constructor: Person, name: ‘xxx‘, age: 22, sayName: function(){ console.log(this.name); } } var p = new Person(); console.log(p.age);//233 p.age = 333; console.log(p.age);//333 </script>
<script> function Person(){ this.age = 233;//创建实例时赋给实例的属性 } Person.prototype = { constructor: Person, name: ‘xxx‘, age: 22, sayName: function(){ console.log(this.name); } } var p = new Person(); console.log(p.age);//233 p.age = 333; console.log(p.age);//333 function Student(){ } Student.prototype = new Person();//继承 var s = new Student(); console.log(s.name);//‘xxx‘ s.name = ‘qqq‘; console.log(s.name);//‘qqq‘ </script>
标签:优先级 xxx col div play 方法 技术 构造 原型
原文地址:https://www.cnblogs.com/Zxq-zn/p/11609903.html