1
00:00:01,464 --> 00:00:05,131
function expression, also known as the

2
00:00:05,131 --> 00:00:07,714
IIFE pattern. The IIFE pattern lets us

3
00:00:07,714 --> 00:00:10,131
group our code and have it work in

4
00:00:10,131 --> 00:00:13,464
isolation independent of any other code.

5
00:00:13,464 --> 00:00:16,893
It stands for immediately invoked function

6
00:00:16,893 --> 00:00:19,839
expression. Let's break it down. A

7
00:00:19,839 --> 00:00:22,089
function expression lets us define a

8
00:00:22,089 --> 00:00:24,464
function and assign it to a variable.

9
00:00:24,464 --> 00:00:26,131
Immediately invoked means invoking the

10
00:00:26,131 --> 00:00:30,464
function immediately where it's defined.

11
00:00:30,464 --> 00:00:33,214
Let's see an example. Here's a regular

12
00:00:33,214 --> 00:00:36,035
function that we have already been working

13
00:00:36,035 --> 00:00:38,214
with. In order to run it, we call the

14
00:00:38,214 --> 00:00:39,464
function name followed by parentheses.

15
00:00:39,464 --> 00:00:42,864
Next, here's the IIFE function that

16
00:00:42,864 --> 00:00:45,214
accomplishes the same thing. However, note

17
00:00:45,214 --> 00:00:48,264
that it doesn't have a name, and it's

18
00:00:48,264 --> 00:00:50,464
completely inside parentheses. Finally, it

19
00:00:50,464 --> 00:00:53,464
has an opening and closing parenthesis

20
00:00:53,464 --> 00:00:56,464
appended to it followed by a semicolon.

21
00:00:56,464 --> 00:01:00,464
This function will be invoked right away.

22
00:01:00,464 --> 00:01:02,321
To make it a function expression, we just

23
00:01:02,321 --> 00:01:08,000
assign it to a variable or use it in some other expression.

