不说废话了,直接上代码
function Foo(){
getName=funtion(){
alert(1)
}
return this;
}
Foo.getName=function(){
alert(2)
}
Foo.prototype.getName=function(){
alret(3)
}
var getName=function(){
alert(4)
}
function getName(){
alert(5)
}
//请写出输出结果
Foo.getName()
getName();
Foo.getName();
getName();
new Foo.getName();
new Foo().getName();
new new Foo().getName();
各位知道答案了吗?可以试一下 2411233
function C1(name){
if(name){
this.name=name;
}
}
function C2(name){
this.name=name;
}
function C3(name){
this.name=name||"john"
}
C1.prototype.name="tom";
C2.prototype.name="tom";
C3.prototype.name="john";
console.log(new C1().name);
console.log(new C2().name);
console.log(new C3().name)
tom underfined John