Skip to main content
100%

this, that and module pattern

✓ Published0🌍 Public
Aabernier
Last edited Aug 5, 2011
Created on Aug 4, 2011

This example illustrates JavaScript’s `this` binding rules across different invocation patterns, using plain console output rather than a visual dataset. It demonstrates how `this` behaves in object methods, immediately invoked function expressions, and module patterns, with the `module.js` file showing a revealed-module approach where a helper function loses its object context. The code relies solely on native JavaScript and the console API, with no external libraries or rendering. The key contrast is between caching `this` into `that` (as in `init.js`) versus relying on implicit binding, which yields either the object or the `DOMWindow` depending on the call site.

AI-generated description

Similar vizzes