How can I make console.log show the current state of an object?

前端 未结 11 1918
走了就别回头了
走了就别回头了 2020-11-22 00:28

In Safari with no add-ons (and actually most other browsers), console.log will show the object at the last state of execution, not at the state when conso

11条回答
  •  轮回少年
    2020-11-22 01:27

    You might want to log the object in a human readable way:

    console.log(JSON.stringify(myObject, null, 2));
    

    This indents the object with 2 spaces at each level.

    How can I pretty-print JSON using JavaScript?

提交回复
热议问题