Tuesday, December 6, 2016

JavaScript Implicitly invoke method - Q&A

Question:

Please describe what will be printed out to the screen and why?

Answer

In the first console.log() the printed result will be a text representation of the func obj. 
This is because getTheName is a pointer (reference) to func object and when we try to print the object we actually call the toString() method.
In the second console.log() the printed result will be Miki. This is because we implicitly invoke the getMashu() method.

No comments:

Post a Comment