function Parent(name,money){
this.name = name;
this.money = money;
this.info = function(){
console.log("姓名:"+this.name+"钱:"+this.money);
}
}
function Children(name){
Parent.call(this,name); //简单继承
this.info = function(){
console.log("姓名:"+this.name);
}
}
var per = new Parent("parent",10000);
var chi = new Children("child");
per.info(); //姓名:parent钱:10000
chi.info(); //姓名:child
function Parent(name,money){
this.name = name;
this.money = money;
this.info = function(){
console.log("姓名:"+this.name+"钱:"+this.money);
}
}
function Children(name,money){
Parent.call(this,name,money); //简单继承
/*this.info = function(){
console.log("姓名:"+this.name);
}*/
}
var per = new Parent("parent",10000);
var chi = new Children("child",20000);
per.info(); //姓名:parent钱:10000
chi.info(); //姓名:child钱:20000
function Parent(name,money){
this.name = name;
this.money = money;
this.info = function(){
console.log("姓名:"+this.name+"钱:"+this.money);
}
}
function Children(name,money){
Parent.call(this,name,money); //简单继承
/*this.info = function(){
console.log("姓名:"+this.name);
}*/
this.info1 = function(){
console.log("info1");
}
}
var per = new Parent("parent",10000);
var chi = new Children("child",20000);
per.info(); //姓名:parent钱:10000
chi.info(); //姓名:child钱:20000
chi.info1(); //info1
-------------------------------------------------------------------------------------
window.color = "red";
var o = {color:"blue"};
function sayColor(){
console.log(this.color);
}
sayColor(); //red
sayColor.call(this);//red
sayColor.call(window); //red
sayColor.call(o); //blue