使用Boolean.prototype,绿色表示true,红色表示false,
如果使用function () { }
,我会得到预期的答案,
但在() => { }
Boolean.prototype.old = function() {
if(this.valueOf() == true){
return "green";
} else{
return "red";
}
}
var v = true;
var x = false;
console.log(v.old());
Boolean.prototype.neww = () => {
if (this.valueOf() == true) {
return "green";
} else {
return "red";
}
};
var v = true;
var x = false;
console.log(v.neww());