/*
*js对象的构造方式
*/


/*混合构造和原型方式*/
function Car(sColor,iDoors)
{
    
this.Color=sColor;
    
this.Doors=iDoors;
    
this.Drivers=new Array("dd","dds");
}

Car.prototype.showColor
=function()
{
    alert(
this.Color);
}


/*动态原型方式*/
function car(sColor,iDoors)
{
    
this.Color=sColor;
    
this.Doors=iDoors;
    
this.Drivers=new Array("dd","dds");

    
if(typeof car._initialized=="undefined")
    {
        Car.prototype.showcolor
=function()
        {
            alert(
this.Color);
        }

        Car._initialized
=true;
    }
}

/*json方式*/

相关文章:

  • 2021-04-17
  • 2021-07-26
  • 2021-08-22
  • 2021-10-30
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-11
  • 2021-11-12
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2021-04-08
  • 2021-06-10
相关资源
相似解决方案