在崇高中,我知道即使你以后没有将更改保存在文件中,也可以从你离开的地方开始.我在sublime中打开了一个新选项卡,并在保存文件之前关闭了应用程序.sublime是否在计算机中的某处保存临时文件(我正在使用MAC OSx)
我试图覆盖我的对象的默认toString方法,这是代码和问题:
function test (){
this.code = 0;//later on I will set these
this.name = "";
}
test.prototype.toString= function(){
return this.name + "\t"+ this.code +" \t "+this.anotherFunction();
}
console.log (Lion.toString()); //works correct i.e. calls my function
console.log (Lion); //doesn't call my function. Prints { code: 0, name: 'jack' }
Run Code Online (Sandbox Code Playgroud)
是不是默认情况下调用toString?