Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Function Prototype Property > The Default prototype Property Is an Object() ...

The Default prototype Property Is an Object() Object

All this prototype talk can get a bit heavy. Truly, prototype is just an empty object property called “prototype” created behind the scenes by JavaScript and made available by invoking the Function() constructor. If you were to do it manually, it would look something like this:

Live Code

<!DOCTYPE html><html lang="en"><body><script>

var myFunction = function() {};
 
myFunction.prototype = {}; /* add the prototype property and set it to an 
                           empty object */

console.log(myFunction.prototype); // logs an empty object

</script></body></html>

In fact, the above code actually works just fine, essentially just duplicating what JavaScript already does.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint