date = new Date();
today = days[date.getDay()];
console.log("Welcome back " + name + ". Today is " +
<< "Welcome back Bart. Today is Sunday"
Safe Use of Strict Mode
In the last chapter we discussed using strict mode to avoid any sloppy coding practices.
One of the problems with simply placing "use strict" at the beginning of a file is that
code, there's no guarantee that they've coded in strict mode.
To avoid this, the recommended way to use strict mode is to place all your code inside an
IIFE, like so:
// All your code would go inside this function
This ensures that only your code inside the IIFE is forced to use strict mode.
Creating Self-contained Modules
An IIFE can be used to enclose a block of code inside its own private scope. This effect-
ively creates a self-contained module that will not interfere with any other part of the pro-
gram. Using IIFEs in this way means that code can be added or removed in a modular fash-
ion. The example shows two modules, A and B, that are able to run code independently of
// Module A
Search WWH ::