This course has been updated! We now recommend you take the Getting Started with JavaScript, v2 course.
Table of Contents
JavaScript Introduction
Introduction
Kyle Simpson begins the course with a brief overview of what he’ll be covering throughout the course. He also recommends a few books and resources as supplemental sources of learning.Kyle’s Work
Kyle spends a few minutes talking about himself and the number of open source projects he manages. He also talks about his You Don’t Know JavaScript book series and how he’ll be using that as a guide for the course.Introduction to Programming
Writing code is nothing more than putting words and phrases into a text editor. These words and phrases are specific to the programming language you are writing. Kyle compares code syntax to the grammar of a spoken language.Statements
A statement is a group of words, numbers and operators that perform a specific task. Most statements end in a semicolon. A computer program is a collection of many statements which carry out the programs purpose.Expressions
Kyle demonstrates how statements can consist of one or more expression. Expressions can be a reference to a variable, a mathematical operation, or even a function call.Executing a Program
Statements and expressions make it easy for developers to tell the program what to do. When it comes time for the computer to execute the code, it needs to be either interpreted or compiled into a language the computer will understand.Practice Coding
Kyle stresses that practicing coding the best way to get more comfortable with the syntax. He spends a few minutes talking about how to use the developer console in a web browser.Input & Output
Kyle demonstrates how to use the console.log() statement to output information into the web browser’s console. This statement is used often for displaying the current value of a variable and testing code execution.
JavaScript Syntax
Operators
JavaScript contains a vast array of operators including mathematical, logical, comparison and equality. Some operators can be written in multiple ways or are a shortcut for a longer form.Values & Types
A Type in JavaScript describes the representation of a value. For example, 42 is a Number and “Hello” is a String. Kyle explains these primitive types and demonstrates how to convert a value from one type to another.Code Comments
Comments are code ignored by the browser. They are useful for adding documentation, notes, or any other text to the source code. Comments can be added to a single line or a block of code. Kyle demonstrates how to use both types of comments and offers a few suggested use-cases.Variables & Blocks
Kyle takes a deeper dive into JavaScript variables. He explains the importance of declaring variables with the “var” keyword and highlights a couple alternative ways to make declarations. Kyle also talks about creating blocks of code with curly braces.Conditional Statements
One major use for block statements is with conditions. An “if” statement checks a condition and will execute the code within its block if the condition is true. If the condition checked is only a value, the value will be converted to a Boolean.Loops
Loops like “for”, “while”, and “do-while” continue to execute a block of code while a condition is true. Kyle starts by demonstrating a “for” loop which uses an iterator to control how many times the loop runs. He then talks about while loops and how the break statement can be used to halt a loops execution.Functions
Functions allow you to create a block of code that can be called at anytime. Functions can also take parameters as input enabling the block of code to run more dynamically. Kyle creates a few different functions and show how to pass parameters and return values.Scope
A variables scope describes the area of the program where the variable is available. For example, if a variable is defined inside a function, it’s only available within the function’s block. A function does have access to any variable defined outside of it’s block.Challenge 1
In this challenge, you will write a program to calculate the total price of your phone purchase. You will keep purchasing phones until you run out of money.Challenge 1 Solution
Kyle walks through the solution to Challenge 1.EcmaScript 6
While answering a few audience questions, Kyle spends a few minutes talking about how developers can start using ES6 syntax in their applications. He demonstrates Babel and ES6 Fiddle and discusses why learning this new syntax is important.