目录
toJSON
b = {
x: 11,
y: 12,
valueOf: function() {
return Math.sqrt(this.x ** 2 + this.y ** 2);
},
toJSON: function() {
return `{x:${this.x},y:${this.y},z:${Math.sqrt(this.x ** 2 + this.y ** 2)}}`;
}
};
console.log(b.toJSON());
console.log(JSON.stringify(b));
b = {
x: 11,
y: 12,
valueOf: function() {…
{x:11,y:12,z:16.278820596099706} debugger eval code:12:9
"{x:11,y:12,z:16.278820596099706}"
标签:11,web,12,return,function,js,杂记,toJSON
From: https://www.cnblogs.com/waterruby/p/17650605.html