javascript(1)공장 방식 js 이미지 대상 의 정의 방법 토론


//60
var ocar=new Object;
ocar.color="black";
ocar.doors=2;
ocar.pinpai=" ";
ocar.showPinpai=function()
{
  alert(this.pinpai);// , ,
}
//70
function createcar()
{
   var oTempCar=new Object;
  oTempCar.color="black";
   oTempCar.doors=4;
   oTempCar.pinpai=" ";
   oTempCar.showPinpai=function()
  {
    alert(this.pinpai);// , ,
  }
    return oTempCar;
}
//80

function createcar(sColor,iDoors,sPinpai)
{
   var oTempCar=new Object;
  oTempCar.color=sColor;
   oTempCar.doors=iDoors;
   oTempCar.pinpai=sPinpai;
   oTempCar.showPinpai=function()
  {
    alert(this.pinpai);// ,
  }
  return oTempCar;
}
//90
function showPinpai()
{
   alert(this.color);
}

function createcar(sColor,iDoors,sPinpai)
{
   var oTempCar=new Object;
  oTempCar.color=sColor;
   oTempCar.doors=iDoors;
   oTempCar.pinpai=sPinpai;
   oTempCar.showPinpai=function()
  return oTempCar;
}
var oBmw=createcar("black",4,"BMW");
oBmw.showColor();// +

좋은 웹페이지 즐겨찾기