0

How can I change this DEBUG code to correspond to the window object as well?

What is the JavaScript equivalent of var_dump or print_r in PHP?


OK

var hoge = new Object();
hoge.q = "stack";
hoge.lang = "js";
hoge.state = 1;

dump(hoge, 'body');

ERROR

dump(hoge, this);

ERROR

dump(hoge, 'window');
Community
  • 1
  • 1
re3
  • 11
  • 6
  • The second argument simply tells the function how to display the result, eg display in page or display in alert box. How would you use `window` in order to display the information? – Patrick Evans Nov 14 '16 at 02:13
  • I wanted to display the WINDOW object debug – re3 Nov 15 '16 at 01:22

1 Answers1

0

you have to define repeatString also, did you?

function repeatString(str, num) {
    out = '';
    for (var i = 0; i < num; i++) {
        out += str; 
    }
    return out;
}

and only dump(hoge, 'body'); would be available to use

payam_sbr
  • 1,428
  • 1
  • 15
  • 24