【发布时间】:2019-06-10 18:59:09
【问题描述】:
我目前正在尝试创建公制和英制比例的单位转换作为数字原型的方法。这是我的代码:
Number.prototype.UnitConversion = function (units){
switch (units){
case "Metric":
this = this/100;
return this;
case "English":
this = this/12;
return this;
}
}
var a = 5;
alert(a.UnitConversion("Metric"))
但是我得到一个左侧无效参数错误。这是为什么呢?
【问题讨论】:
标签: javascript numbers prototype