Some sample JavaScript code snippets for:
- Creating a function declaration.
- Creating a function expression.
- Showing that function declarations are hoisted but function expressions are not.
- Showing that function expressions may be unnamed or anonymous.
- Using arrow functions that contain one or multiple statements.
Instructions for use
- the web page containing the JavaScript code.
- Open the page in Brave or other, lesser web browsers.
- View the JavaScript output by pressing the following keys and selecting the Console tab:
- Ctrl + Shift + i (Windows)
- ⌘ Command + Shift + i (Mac).
- Open the web page in VS Code, VS Code Online or Sublime Text. All are good choices.
- Play around with the JavaScript code. Change things and see what happens.
✅ That’s it.