Part 04 - Advanced JavaScript
Part 04 - Advanced JavaScript
● Variable Hoisting
● Class Hoisting
11/30/2024 Dr. Amjad AbuHassan 3
Outline
● Variables
● Arrow Functions vs Function Expression
● Modules
● Promises and Asynchronous Programming
● Closures
● Generators
● Higher-Order Functions
● this Keyword
11/30/2024 Dr. Amjad AbuHassan 4
Variables
● let
● const
● While all these variable declarations are hoisted, they each behave differently
● Updating Variables:
● var variables can be updated and re-declared within their scope.
● let variables can be updated but not re-declared within the same scope.
● let and const variables are not initialized (Temporal Dead Zone).
● Initialization Requirement:
● var and let can be declared without initialization.
● Understanding their syntax, behavior, and use cases helps in writing efficient and
maintainable code.
● Consistent this Context: When the this value should remain the same.
● Short Inline Functions: Perfect for simple, one-liner functions.
● Callbacks:
● Arguments Object:
● Arrow Functions: Do not have their
● Function Expressions:
● If declared with var, they are hoisted but initialized as undefined.
● Default Exports:
● Allows you to export a single default value.
● Module scripts are deferred by default, executing after the document has been parsed.
● Common Use Cases: Network requests, file operations, timers, user interactions.
● Calling a Generator: