filmov
tv
Modular Javascript #3 - Revealing Module Pattern Javascript Tutorial
Показать описание
The revealing module pattern allows us to create private variables in a Javascript Module.
Here's a writeup on this pattern:
Here's the code for this video:
Here's video 1 in case you missed it:
We write a revealing module pattern by starting with a self-executing anonymous function also known as an IIFE (immediately invoked function expression).
This runs a function and sets it's return value as our module's value. If we return an object of methods, then those methods are what other modules have "public" access to. What's nice about this, is we can create any variables within the function and no other modules have access to them unless we expose them via our return object.
Modular JS #1 - Object Literal Pattern pt 1:
Modular JS #2 - Object Literal Pattern pt 2:
Modular JS #3 - Revealing Module Pattern:
-~-~~-~~~-~~-~-
Also watch: "Responsive Design Tutorial - Tips for making web sites look great on any device"
-~-~~-~~~-~~-~-
Here's a writeup on this pattern:
Here's the code for this video:
Here's video 1 in case you missed it:
We write a revealing module pattern by starting with a self-executing anonymous function also known as an IIFE (immediately invoked function expression).
This runs a function and sets it's return value as our module's value. If we return an object of methods, then those methods are what other modules have "public" access to. What's nice about this, is we can create any variables within the function and no other modules have access to them unless we expose them via our return object.
Modular JS #1 - Object Literal Pattern pt 1:
Modular JS #2 - Object Literal Pattern pt 2:
Modular JS #3 - Revealing Module Pattern:
-~-~~-~~~-~~-~-
Also watch: "Responsive Design Tutorial - Tips for making web sites look great on any device"
-~-~~-~~~-~~-~-
Комментарии