View list of all JavaScript variables in Google Chrome Console

后端 未结 15 2131
星月不相逢
星月不相逢 2020-11-29 14:32

In Firebug, the DOM tab shows a list of all your public variables and objects. In Chrome\'s console you have to type the name of the public variable or object you want to ex

15条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 15:05

    List the variable and their values

    for(var b in window) { if(window.hasOwnProperty(b)) console.log(b+" = "+window[b]); }
    

    Display the value of a particular variable object

    console.log(JSON.stringify(content_of_some_variable_object))
    

    Sources: comment from @northern-bradley and answer from @nick-craver

提交回复
热议问题