[英]Setter method passes in a string as undefined (javascript)
_srwc.push(['setShowPrice',true, "Hello", " Test"]);
我有上面的设置器,它将一个布尔值和两个字符串传递给下面的函数...
function setShowPrice(show, prefix, suffix){
sophiaShowPrice = show;
pricePrefix = prefix;
priceSuffix = suffix;
console.log("prefix passed in = " + prefix);
console.log("suffix passed in = " + suffix);
console.log("price prefix = " + pricePrefix);
console.log("price suffix = " + priceSuffix);
if (priceSuffix == undefined){
priceSuffix = " ";
}
if (pricePrefix == undefined){
pricePrefix = " ";
}
}
在控制台日志中,前缀正确显示“ hello”,但后缀显示为undefined。 这两个变量都与函数一样在同一文件中创建...
var pricePrefix = "";
var priceSuffix = "";
为什么第二个字符串被读取为undefined?
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.