Explain what the following code prints to the console.

function pirate () {
  return this;


The pirate() function returns the global window object. The global window object is created by the JavaScript interpreter when it is started to store built-in constructor functions, global constants, and global properties. When functions are invoked as functions (i.e. they are in the global namespace and are not part of an object or constructor function), the value of the this keyword is the global object.


© 2017