Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've always noticed this, but never actually understood what's happening here. I have a fairly simple object that I've put in a console.log. It has a seemingly never ending pattern of prototype -> constructor -> prototype -> etc. What exactly is it's purpose?

enter image description here

share|improve this question
up vote 3 down vote accepted

It doesn't have a purpose. As you can see, it only annoys you without giving out any additional information. It only has a reason.

What's happening is that the structure you're printing has a cyclical reference (the prototype knows about the contructor, and the constructor knows about its prototype), and the logger isn't smart enough to realize it will never finish if it naively follows all references.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.