重学JS 3

// JavaScript创建一个对象
var  company = {
 name:”IBM”,
 product:”softwares”,
 employees:{name: “frank”,age: 26 }

}  
// 创建一个对象    
function  fun(){}; 
var  obj = {};
fun.call(obj); 

//JavaScript 的继承

function fruit(name){  this .name  =  name; 
 this .flower =   function (){
        alert( ' Hello,I am '   + this .name);
    }
}  
function  apple(name,color){
    fruit.call( this ,name);  this .color  =  color;  
    this .showColor  =   function (){
        alert( this .color + '  color ' );
    }
}  
var  bananer  =   new  fruit( ' bananer ' ); 
var  greenApple  =   new  apple( ' greenApple ' , ' green ' ); 

bananer.flower();
greenApple.flower();
greenApple.showColor(); 

你可能感兴趣的:(重学JS 3)