checkoutParameters = (@serviceName, @merchantID, @options) ->
#空的函数体生成的js,不需要加return:
var checkoutParameters;
checkoutParameters = function(serviceName, merchantID, options) {
this.serviceName = serviceName;
this.merchantID = merchantID;
this.options = options;
};
cartItem = (@sku, @name, price, quantity) ->
@price = price*1
@quantity = quantity*1
return
# 非空的函数体,需要加return
var cartItem;
cartItem = function(sku, name, price, quantity) {
this.sku = sku;
this.name = name;
this.price = price * 1;
this.quantity = quantity * 1;
};
上面如果没有return,下面将是
return this.quantity = quantity * 1;
作为对象的构造函数,这是我们不希望看到的。
var checkoutParameters;
checkoutParameters = function(serviceName, merchantID, options) {
this.serviceName = serviceName;
this.merchantID = merchantID;
this.options = options;
};
cartItem = (@sku, @name, price, quantity) ->
@price = price*1
@quantity = quantity*1
return
# 非空的函数体,需要加return
var cartItem;
cartItem = function(sku, name, price, quantity) {
this.sku = sku;
this.name = name;
this.price = price * 1;
this.quantity = quantity * 1;
};
上面如果没有return,下面将是
return this.quantity = quantity * 1;
作为对象的构造函数,这是我们不希望看到的。