Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object Dump JavaScript

Tags:

javascript

Is there a 3rd party add-on/application or some way to perform object map dumping in script debugger for a JavaScript object?

Here is the situation... I have a method being called twice, and during each time something is different. I'm not sure what is different, but something is. So, if I could dump all the properties of window (or at least window.document) into a text editor, I could compare the state between the two calls with a simple file diff. Thoughts?

like image 613
Jessy Houle Avatar asked Apr 14 '09 20:04

Jessy Houle


People also ask

Is there a Var_dump in JavaScript?

The var_dump equivalent in JavaScript? Simply, there isn't one. Prints an interactive listing of all properties of the object. This looks identical to the view that you would see in the DOM tab.

How do you log an object in JavaScript?

Method 1 — Use console.log() method called with an object or objects as arguments will display the object or objects. Of course, not all JavaScript is developed in or can be debugged in browsers — so developers may be using alert() instead of console. log() .


2 Answers

console.log("my object: %o", myObj) 

Otherwise you'll end up with a string representation sometimes displaying:

[object Object] 

or some such.

like image 109
Tim Avatar answered Sep 23 '22 00:09

Tim


Firebug + console.log(myObjectInstance)

like image 30
Darin Dimitrov Avatar answered Sep 25 '22 00:09

Darin Dimitrov