InterviewSolution
Saved Bookmarks
| 1. |
JavaScript Native Objects? |
|
Answer» The JAVASCRIPT engine adds a prototype property to the function when a function is created. This prototype property is an object. The objects inherit the properties and methods from their prototype. Access the function’s prototype property using the following syntax: functionName.prototypeHere’s an EXAMPLE: <!DOCTYPE html> <html> <BODY> <h2>Player</h2> <p ID="DETAILS"></p> <script> function Team(rank, name) { this.rank = rank; this.name = name; } var res = new Team("3", "Jacob"); document.getElementById("details").innerHTML = "The name of the Player is " + res.name; </script> </body> </html>The output: |
|