
Getting Started with JavaScript, v2
Learning Paths:
Topics:
Table of Contents
Introduction
Introduction
Kyle Simpson introduces the course on beginning to program in JavaScript and demonstrates several basic parts of a program working together.Course Overview
Kyle gives an overview of what will be covered in the course, including a primer on the main concepts of programming and also the three pillars of JavaScript: types and coercion, scope and closure, and this and prototypes.
Programming Primer
Values
Kyle presents examples of different kinds of values. Differences are given between primitive and non-primitive values, and between array indexes and object properties.Operations
Kyle presents examples of different kinds of operations that can be performed, including addition, subtraction and comparison. After explaining what each does, Kyle runs the code to show how they evaluate.Types
Kyle demonstrates how the typeof unary operator can be used to reveal the type of a value, including number, string, boolean, undefined, and object.Variables
Kyle explains what variables are, walking through how to use the assignment operator to assign a variable's value and then how to access the value. Empty values and semicolons are also discussed.Expressions vs Statements
Kyle differentiates between expressions and statements and then counts the number of expressions in an example statement. Kyle later runs an expression and statement to show how they evaluate.If & Else
Kyle introduces control flow in JavaScript in the form of if and else statements, and explains the power this gives to the programmer. Kyle then runs a program with an if else statement.Loops
Kyle introduces loops by describing for loops, for of loops, and while loops. After explaining why loops are used, Kyle then runs a while loop to demonstrate how the while loop is working.Functions
Kyle explains why it is useful to group code together into a function, highlights the parts of a function signature, and shows what a function evaluates to after changing its arguments and running it.Programming Primer Exercise
Kyle instructs students to use the basic programming principles learned in previous lessons to work through an exercise on adding strings to an array, then looping through the array.Programming Primer Solution
Kyle live codes the solution to the exercise.Programming Primer Summary
Kyle summarizes the programming primer section of the course, suggests resources for learning more about mentioned concepts, and discusses what will be covered in the course next.
Types & Coercion
Primitive Types
Kyle introduces primitive types by debunking the myth that everything in JavaScript is an object and then explains what it means for the type to belong to the value in JavaScript instead of the variable.NaN
Kyle explains what NaN is, when a NaN will be returned, how to test if a value is of the type NaN, and in what situations it is beneficial to test for NaN values.new
Kyle differentiates between situations where new should be used to create instances of object representations and when not to use new, and instead by omitting it allow for type conversion to occur.Coercion
Kyle introduces coercion by explaining when it occurs, discussing how the plus operator is overloaded related to coercion, and walking through instances of number and string coercion.Booleans
Kyle displays the list of falsy and truthy values in JavaScript, and explains how the falsy list can be used to know which values will become true or false during conversion to a boolean value. Examples are given in the form of if and while statements.Coercion Best Practices
Kyle argues for making types and type conversions obvious, and frames the quality of a program related to types in terms of the reader of the code.Equality
Kyle distinguishes between the double and triple equals, and dives into how each works under the hood related to type conversions. A case is made for not always choosing the triple equals.Types Summary
Kyle summarizes the section on types by advocating for critical thinking around how to use types in a program, when to allow type coercion, and when to disallow it.
Scope
Scope
Kyle introduces scope as the rules for where to look for things and walks through the process of how variables are being looked up in a few lines of code.Undefined vs Undeclared
Kyle explains how the two concepts around emptiness in JavaScript, undefined and undeclared, differ.Function Expressions
Kyle defines what a function expression is and then performs side-by-side comparisons between named and anonymous function expressions to argue that naming increases readability.IIFEs
Kyle discusses when it is beneficial to use the IIFE pattern to create immediately invoked function expressions.Block Scoping with let
Kyle explains how to use block scoping as a tool to selectively make variables available, with the let keyword protecting a value from being accessed in an outer scope.Closure
Kyle explains what it means for closure to occur in a program and how to use closure advantageously when passing functions to other functions.
this & Prototypes
this
Kyle demonstrates how the this keyword in JavaScript's dynamic context system references the execution context of a function call in order to access values that are specific to that function call.Prototypes
Kyle introduces prototypal inheritance in JavaScript through an example where a method is added to a constructor's prototype and is then available to instances created using the constructor.class
Kyle explains how the class keyword works in JavaScript by displaying code using the class syntax that achieves the same result as code that uses the prototypal inheritance pattern.
Practice
Three Pillars of JS Exercise
Kyle instructs students to build off of code from the first exercise by incorporating elements of types, scope and closure, and the this and prototypes system.Three Pillars of JS Solution
Kyle live codes the solution to the exercise.Pillars of JS Summary
Kyle reviews what was learned about the three pillars of JavaScript and gives tips about how to continue growing as a JavaScript developer.