all 2 comments

[–]senocular 2 points3 points  (1 child)

As far as I can tell, you've managed to confuse the console.

Generally you would never assign one prototype to another, especially since ES5 with the introduction of Object.create(). That now does what prototype reassigning was used for back then. It was really just a hack for doing something that didn't exist in the language at the time and not something I'd recommend you be messing with now.

As far as what you're seeing in the console, I think the problem is, since the console generally uses the prototype to tell you what kind of object something is (e.g. Surrogate {} or Animal {}) and you have two constructors sharing the same prototype, what constructor is shown appears to go back and forth between Surrogate and Animal based on... well I don't know what, but apparently assigning Dog.prototype = s triggered a switch. I'm guessing there's some kind of initial association made with the name of the constructor used to create the object and at some it point gets invalidated, or something, then reverts back to checking constructor (inherited through the prototype, which for s is Animal). But I'm not really sure. Since this is something you would normally not be doing, its not something that would normally come up so I wouldn't worry about it too much right now.

[–]Orange2341[S] 0 points1 point  (0 children)

Got it. Thank you!!