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
  • 20,493
  • 5
  • 36
  • 47
Amnah khatun
  • 185
  • 1
  • 4
  • 14
  • 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 – Amnah khatun 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,256
  • 9
  • 22