Last active
August 29, 2015 14:02
-
-
Save jikeytang/441222c0a9747b8ff015 to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140620-题目1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
用代码实现函数B继承函数A里边的全部属性与方法,且覆盖函数A其中的sayName方法。 | |
PS: | |
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。 | |
```javascript | |
// you code | |
``` | |
2. 粘贴代码时请使用shift+tab,缩进前面的空白。 |
ljkfgh2008
commented
Jun 20, 2014
function A(name){
this.name = name;
}
A.prototype.sayName = function(){
console.log("this is A sayName method");
console.log(this.name);
}
function B(name){
A.call(this, name);
}
B.prototype = new A();
B.prototype.sayName = function(){
console.log("this is B sayName method");
console.log(this.name);
}
var b = new B("b");
b.sayName();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment