Modules, Functions and Types
Mastering the fundamentals of JavaScript pays huge dividends, as we start diving into the language features that are slightly newer and more complex.
-
Modules, Functions and TypesWelcome
Get to know each other, and ensure everyone has the course projects installed properly.
-
Modules, Functions and TypesTypes and Operators
At the foundation of JavaScript are a few fundamental types and operators. We'll look at each of these in detail, highlighting and clarifying some counterintuitive aspects of the language.
-
Modules, Functions and TypesBasic Functions
Functions are first class values in JavaScript, meaning they can exist on their own and used wherever any other value can be used. We'll look at the basics of how functions are declared, defined and used in JavaScript.
-
Modules, Functions and TypesBasic Objects
Objects serve as the foundation for all mutable data structures in JavaScript. They're incredibly flexible, in that they can contain data, value based properties, and even getter and setter based properties.
-
Modules, Functions and TypesEXERCISE: Two Kinds of Color
Using a property descriptor, define a property on an object that's derived from other values. We should be able to get and set this property just as if it were value based, and the getter and setter you define should keep all of the dependencies in sync properly.
-
Modules, Functions and TypesModules
Thankfully, the JavaScript ecosystem has standardized around a single type of "module". We'll compare this current standard to some widely-adopted predecessors (CommonJS and Named AMD modules), highlighting new capabilities and future potential. Finally, we'll discuss some topics that are currently under discussion in the TC39 working group (the JavaScript standards body).
-
Modules, Functions and TypesEXERCISE: Refactoring into Modules
Take a solution from the previous exercise and refactor it, so that the heavy lifting is done by two pure functions in a separate module.
-
Modules, Functions and TypesCoffee Break
Coffee Break
-
Modules, Functions and TypesDeeper Functions
New advancements in the JavaScript standard have made concepts like arrow functions commonplace, and upcoming improvements to modern runtimes will give us what we need to treat it like a true functional programming language. We'll look at higher order functions, named vs unnamed functions, the concept of lexical scope, and different ways we can invoke functions.
-
Modules, Functions and TypesEXERCISE: Functional Cart
Build a shopping cart that takes advantage of a closure's ability to hold state (and functions defined within that closure to access that state).
-
Modules, Functions and TypesLunch
Break for lunch