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 > Prototype Is Standard on All function() Instan...

Prototype Is Standard on All function() Instances

All functions are created from a Function() constructor, even if you do not directly invoke the Function() constructor (e.g., var add = new Function('x', 'y', 'return x + z');) and instead use the literal notation (e.g., var add = function(x,y){return x + z};).

When a function instance is created, it is always given a prototype property, which is an empty object. Below, we define a function called myFunction, then we access the prototype property, which is simply an empty object.

Live Code

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

var myFunction = function() {};
console.log(myFunction.prototype); // logs object{}
console.log(typeof myFunction.prototype); // logs 'object'

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

  

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