1str = JSON.stringify(obj);
2str = JSON.stringify(obj, null, 4); // (Optional) beautiful indented output.
3console.log(str); // Logs output to dev tools console.
4alert(str); // Displays output using window.alert()
1const util = require('util')
2
3console.log(util.inspect(myObject, {showHidden: false, depth: null}))
4
5// alternative shortcut
6console.log(util.inspect(myObject, false, null, true /* enable colors */))
1
2var person = {name:"John", age:30, city:"New York"};
3
4
5document.getElementById("demo").innerHTML = person;
6