1

I want to see function body of console.log function. To check this I tried following code :

console.log(console.log.toString())    

It prints only

function () { [native code] }

So how can I check this code?

zangw
  • 43,869
  • 19
  • 177
  • 214

1 Answers1

1

You can't. It is a native function, which under most browsers means it is written in a lower-level language like C.

If you can explain why you would like the source, we might be able to help.

Jeremy J Starcher
  • 23,369
  • 6
  • 54
  • 74
  • 1
    When I pass circular object to console.log,it prints correctly. Whereas when I use winston for logging & pass circular object,it goes into infinite loop.So I want to check ,how it is handled in console.log. – Abhishek Kulkarni Mar 09 '16 at 05:14
  • 1
    Each browser is free to handle it howeer they'd like.. but -- there are some JSON encoders that can handle circular data. One of them might be able to help you. http://stackoverflow.com/questions/9382167/serializing-object-that-contains-cyclic-object-value or google for Circle JavaScript Encoder. – Jeremy J Starcher Mar 09 '16 at 05:42
  • Thanks Jeremy, Your comment helps me & gave a proper direction to this problem. – Abhishek Kulkarni Mar 09 '16 at 05:49