console.log showing contents of array object

后端 未结 7 1815
没有蜡笔的小新
没有蜡笔的小新 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 17:04

    I warmly recommend this snippet to ensure, accidentally left code pieces don't fail on clients browsers:

    /* neutralize absence of firebug */
    if ((typeof console) !== 'object' || (typeof console.info) !== 'function') {
        window.console = {};
        window.console.info = window.console.log = window.console.warn = function(msg) {};
        window.console.trace = window.console.error = window.console.assert = function(msg) {};
    }
    

    rather than defining an empty function, this snippet is also a good starting point for rolling your own console surrogate if needed, i.e. dumping those infos into a .debug Container, show alerts (could get plenty) or such...

    If you do use firefox+firebug, console.dir() is best for dumping array output, see here.

    0 讨论(0)
提交回复
热议问题