Javascript
JavaScript Fundamentals -- The this Keyword
  •  

Global Context

PRO
Outline

The global context is the fallback context in JavaScript. If you run a function and no context is set (usually by an object, which we'll cover in upcoming videos) then the fallback is the global context. In Node.js, that means an object with information related to Node. In the browser, the global context is the Window object.

If you run a file in strict mode, then JavaScript leaves this undefined if it's not actually set. It means there is no fallback object, and if you're using this you'll get undefined. If you try to access this.someAttribute, you'll get an uncaught type error for trying to access an attribute of undefined.

For more information on this in JavaScript, go read this blog post.

 

I finished! On to the next chapter