How to inspect Javascript Objects

后端 未结 8 557
半阙折子戏
半阙折子戏 2020-12-07 10:31

How can I inspect an Object in an alert box? Normally alerting an Object just throws the nodename:

alert(document);

But I want to get the p

8条回答
  •  醉酒成梦
    2020-12-07 11:03

    How about alert(JSON.stringify(object)) with a modern browser?

    In case of TypeError: Converting circular structure to JSON, here are more options: How to serialize DOM node to JSON even if there are circular references?

    The documentation: JSON.stringify() provides info on formatting or prettifying the output.

提交回复
热议问题