0

When I am running this piece of code in JSEditor.

var obj = {}; 
console.log(obj); 
obj.foo = 'bar';

The o/p is : [object Object]

While the same code in the console tab is giving me this o/p:

{}
"bar"
Hassan Imam
  • 21,956
  • 5
  • 41
  • 51
The IT gal
  • 197
  • 1
  • 5
  • 15
  • I recommend [https://repl.it/languages/javascript](https://repl.it/languages/javascript) – Mulan Jan 08 '19 at 07:27
  • Possible duplicate of [What's the difference between console.dir and console.log?](https://stackoverflow.com/questions/11954152/whats-the-difference-between-console-dir-and-console-log) – jned29 Jan 08 '19 at 07:29
  • It worked fine when I ran my code using the link you have provided. @user633183 – The IT gal Jan 08 '19 at 07:37

1 Answers1

0

In node js

console instance configured to write to process.stdout and process.stderr. The global console can be used without calling require('console').

var p={}

console.log function uses process.stdout.write();process.stdout

So you will get object after writing the value

Biswadev
  • 1,456
  • 11
  • 24