开发者

An error has occured: [object Object] error. ?

The cause of the error in my code(DEMO) a开发者_开发技巧nd how to fix?

An error has occured:

[object Object]

error

DEMO


Change this:

alert("An error has occured:\n" + x + "\n" + y + "\n" + z);

Problem is that String + Object results in the Object being converted into a String, the default result is what you see as [Object object].

Possible solutions:

  1. On custom objects define a toString() and return whatever you want to see in the output.
  2. use JSON.stringify(obj) to convert it into something more useful, this will of course break in cases where circular references exist.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜