this.price=fprice(); ------//定义一个对像方法,由于方法在对像外定义,就相当于将fprice()绑定到price上
price=sweater.price();   --------//调用price函数其实也就是调用fprice()

解决方案 »

  1.   

    你的这个函数应该有一个类吧,$this就是代表当前对像呀
    price=sweater.price();   --------如果是调用的类的方法的话就是说,调用sweater对像的.price方法的返回值给price变量this.price=fprice(); ------当前对像的price的变量值为fprice函数的返回值
      

  2.   

    建议楼主看看thinking in java 这样的面向对像的书
      

  3.   

    我对楼上见解有所疑议,
    this.price=fprice();是JS里的方法定义
    定义过后this.price()就是topwear类的一个方法,而它的原型则是前面定义的fprice
    这个和下面定义应该是一样的this.price = function ()
    {
    var startprice=10.00;
    var addcost=0;
    if(this.material=="cotton"){addcost=5.50};
    if(this.material=="nylon"){addcost=2.50};
    if(this.material=="atgyle"){addcost=20.00};
    return startprice+addcost;
    }