console.log showing contents of array object

后端 未结 7 1826
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 16:02

I have tried using console.log so I can see the content of my array that contains multiple objects. However I get an error saying console.log is not an

7条回答
  •  星月不相逢
    2021-01-30 16:50

    It's simple to print an object to console in Javascript. Just use the following syntax:

    console.log( object );
    

    or

    console.log('object: %O', object );
    

    A relatively unknown method is following which prints an object or array to the console as table:

    console.table( object );

    I think it is important to say that this kind of logging statement only works inside a browser environment. I used this with Google Chrome. You can watch the output of your console.log calls inside the Developer Console: Open it by right click on any element in the webpage and select 'Inspect'. Select tab 'Console'.

提交回复
热议问题