Check out all our Tutorial Series ->
// Tutorial Series //
How To Code in JavaScript
How To Code in JavaScript

Introduction

JavaScript is a high-level, object-based, dynamic scripting language popular as a tool for making webpages interactive.

Summary View
detailed View
// Tutorial //

How To Use the JavaScript Developer Console

Published on June 29, 2017 · Updated on May 19, 2022

This tutorial will go over how to work with the Console in JavaScript within the context of a browser, and provide an overview of other built-in development tools you may use as part of your web development process.

// Tutorial //

How To Add JavaScript to HTML

Published on June 30, 2017 · Updated on August 20, 2021

This tutorial will go over how to incorporate JavaScript into your web files, both inline into an HTML document and as a separate file.

// Tutorial //

How To Write Your First JavaScript Program

Published on August 2, 2017 · Updated on August 23, 2021

This tutorial will walk you through creating a “Hello, World!” program in JavaScript. To make the program more interesting, we’ll modify the traditional “Hello, World!” program so that it asks the user for their name. We’ll then use the name in a greeting. When you’re done with this tutorial, you’ll have an interactive “Hello, World!” program.

// Tutorial //

Understanding Syntax and Code Structure in JavaScript

Published on July 5, 2017 · Updated on August 23, 2021

In this tutorial, we’ll go over many of the rules and conventions of JavaScript syntax and code structure.

// Tutorial //

How To Write Comments in JavaScript

Published on June 20, 2017 · Updated on August 30, 2021

JavaScript comments are annotations in the source code of a program that are ignored by the interpreter, and therefore have no effect on the actual output of the code. Comments can be immensely helpful in explaining the intent of what your code is or should be doing.

// Tutorial //

Understanding Data Types in JavaScript

Published on June 1, 2017 · Updated on August 23, 2021

In this tutorial, we will go over how data types work in JavaScript as well as the important data types native to the language.

// Tutorial //

How To Work with Strings in JavaScript

Published on July 11, 2017 · Updated on August 24, 2021

A string is a sequence of one or more characters that may consist of letters, numbers, or symbols. Strings in JavaScript are primitive data types and immutable, which means they are unchanging. As strings are the way we display and work with text, and text is our main…

// Tutorial //

How To Index, Split, and Manipulate Strings in JavaScript

Published on July 14, 2017 · Updated on August 24, 2021

In this tutorial, we will learn the difference between string primitives and the String object, how strings are indexed, how to access characters in a string, and common properties and methods used on strings.

// Tutorial //

How To Convert Data Types in JavaScript

Published on August 15, 2017 · Updated on August 24, 2021

This tutorial will guide you through converting JavaScript’s primitive data types, including numbers, strings, and Booleans.

// Tutorial //

Understanding Variables, Scope, and Hoisting in JavaScript

Published on February 20, 2018 · Updated on August 24, 2021

This tutorial covers what variables are, how to declare and name them, and also take a closer look at the difference between var, let, and const. It also goes over the effects of hoisting and the significance of global and local scope to a variable’s behavior.

// Tutorial //

How To Do Math in JavaScript with Operators

Published on July 20, 2017 · Updated on August 24, 2021

In this JavaScript tutorial, we will go over arithmetic operators, assignment operators, and the order of operations used with number data types.

// Tutorial //

Understanding Comparison and Logical Operators in JavaScript

Published on February 5, 2021 · Updated on August 24, 2021

The field of computer science has many foundations in mathematical logic. If you have a familiarity with logic, you know that it involves truth tables, Boolean algebra, and comparisons to determine equality or difference. The JavaScript programming language uses operators…

// Tutorial //

Understanding Arrays in JavaScript

Published on July 28, 2017 · Updated on August 24, 2021

In this tutorial, we will learn how to create arrays; how they are indexed; how to add, modify, remove, or access items in an array; and how to loop through arrays.

// Tutorial //

How To Use Array Methods in JavaScript: Mutator Methods

Published on August 10, 2017 · Updated on August 25, 2021

JavaScript has many useful built-in methods to work with arrays. Methods that modify the original array are known as mutator methods, and methods that return a new value or representation are known as accessor methods. In this tutorial, we will focus on mutator methods.

// Tutorial //

How To Use Array Methods in JavaScript: Accessor Methods

Published on August 14, 2017 · Updated on August 25, 2021

This tutorial will go over methods that will concatenate arrays, convert arrays to strings, copy portions of an array to a new array, and find the indices of arrays.

// Tutorial //

How To Use Array Methods in JavaScript: Iteration Methods

Published on August 15, 2017 · Updated on August 25, 2021

In JavaScript, the array data type consists of a list of elements. There are many useful built-in methods available for JavaScript developers to work with arrays. In this tutorial, we will use iteration methods to loop through arrays, perform functions on each item in an array, filter the desired results of an array, reduce array items down to a single value, and search through arrays to find values or indices.

// Tutorial //

Understanding Objects in JavaScript

Published on August 24, 2017 · Updated on August 25, 2021

Objects are an integral and foundational aspect of most JavaScript programs. For example, a user account object may contain such data as usernames, passwords, and e-mail addresses. Another common use case is a web shopping platform’s shopping cart that could consist of an array of many objects containing all the pertinent information for each item, such as name, price, and weight for shipping information. A to-do list is another common application that might consist of objects.

// Tutorial //

Understanding Date and Time in JavaScript

Published on October 19, 2017 · Updated on August 25, 2021

JavaScript comes with the built in Date object and related methods. This tutorial will go over how to format and use date and time in JavaScript.

// Tutorial //

Understanding Events in JavaScript

Published on June 19, 2018 · Updated on August 25, 2021

Events are actions that take place in the browser that can be initiated by either the user or the browser itself. In this JavaScript aticle, we will go over event handlers, event listeners, and event objects. We’ll also go over three different ways to write code to handle events, and a few of the most common events. By learning about events, you’ll be able to make a more interactive web experience for end users.

// Tutorial //

How To Work with JSON in JavaScript

Published on December 9, 2016 · Updated on August 25, 2021

This tutorial provides an introduction to working with JSON in JavaScript. Some general use cases of JSON include: storing data, generating data from user input, transferring data from server to client and vice versa, configuring and verifying data.

// Tutorial //

How To Write Conditional Statements in JavaScript

Published on August 29, 2017 · Updated on August 25, 2021

In programming, there will be many occasions in which you will want different blocks of code to run depending on user input or other factors. As an example, you might want a form to submit if each field is filled out properly, but you might want to prevent that form from…

// Tutorial //

How To Use the Switch Statement in JavaScript

Published on September 11, 2017 · Updated on August 26, 2021

Conditional statements are among the most useful and common features of all programming languages. “How To Write Conditional Statements in JavaScript” describes how to use the…

// Tutorial //

Using While Loops and Do...While Loops in JavaScript

Published on September 27, 2017 · Updated on August 26, 2021

Automation is the technique of making a system operate automatically; in programming, we use loops to automate repetitious tasks. Loops are one of the most useful features of programming languages, and in this this article we will learn about the while and do…while…

// Tutorial //

For Loops, For...Of Loops and For...In Loops in JavaScript

Published on October 2, 2017 · Updated on August 26, 2021

Loops are used in programming to automate repetitive tasks. In this tutorial, we will learn about the for statement, including the for…of and for…in statements, which are essential elements of the JavaScript programming language.

// Tutorial //

How To Define Functions in JavaScript

Published on October 9, 2017 · Updated on August 26, 2021

A function is a block of code that performs an action or returns a value. Functions are custom code defined by programmers that are reusable, and can therefore make your programs more modular and efficient. In this tutorial, we will learn several ways to define a…

// Tutorial //

Understanding Prototypes and Inheritance in JavaScript

Published on January 12, 2018 · Updated on August 26, 2021

JavaScript is a prototype-based language, meaning object properties and methods can be shared through generalized objects that have the ability to be cloned and extended. This is known as prototypical inheritance and differs from class inheritance. Among popular…

// Tutorial //

Understanding Classes in JavaScript

Published on May 4, 2018 · Updated on August 26, 2021

Understanding prototypical inheritance is paramount to being an effective JavaScript developer. Being familiar with classes is extremely helpful, as popular JavaScript libraries such as React make frequent use of the class syntax.

// Tutorial //

How To Use Object Methods in JavaScript

Published on August 3, 2018 · Updated on August 26, 2021

Objects in JavaScript are collections of key/value pairs. The values can consist of properties and methods, and may contain all other JavaScript data types, such as strings,…

// Conceptual-article //

Understanding This, Bind, Call, and Apply in JavaScript

Published on October 3, 2019 · Updated on August 26, 2021

The this keyword is a very important concept in JavaScript, and also a particularly confusing one to both new developers and those who have experience in other programming languages. In JavaScript, this is a reference to an object. In this article, you’ll learn what this refers to based on context, and you’ll learn how you can use the bind, call, and apply methods to explicitly determine the value of this.

// Tutorial //

Understanding Map and Set Objects in JavaScript

Published on February 12, 2020 · Updated on August 27, 2021

Introduced in ECMAScript 2015, Maps in JavaScript are ordered collections of key/value pairs, and Sets are collections of unique values. In this article, you will go over the Map and Set objects, what makes them similar or different to Objects and Arrays, the properties and methods available to them, and examples of some practical uses.

// Tutorial //

Understanding Generators in JavaScript

Published on February 28, 2020 · Updated on August 27, 2021

In ECMAScript 2015, generators were introduced to the JavaScript language. A generator is a process that can be paused and resumed and can yield multiple values. They can maintain state, providing an efficient way to make iterators, and are capable of dealing with infinite data streams. In this article, we’ll cover how to create generator functions, how to iterate over Generator objects, the difference between yield and return inside a generator, and other aspects of working with generators.

// Tutorial //

Understanding Default Parameters in JavaScript

Published on March 31, 2020 · Updated on August 27, 2021

In ECMAScript 2015, default function parameters were introduced to the JavaScript programming language. These allow developers to initialize a function with default values if the arguments are not supplied to the function call. Initializing function parameters in this way will make your functions easier to read and help you avoid errors caused by undefined arguments and the destructuring of objects that don’t exist. In this article, you will learn how to use default parameters.

// Tutorial //

Understanding Destructuring, Rest Parameters, and Spread Syntax in JavaScript

Published on May 12, 2020 · Updated on August 27, 2021

Introduced in ECMAScript 2015 (ES6), destructuring, rest parameters, and spread syntax provide more direct ways of accessing the members of an array or an object, and can make working with data structures quicker and more succinct. In this article, you will learn how to destructure objects and arrays in JavaScript, how to use the spread operator to unpack objects and arrays, and how to use rest parameters in function calls.

// Tutorial //

Understanding Template Literals in JavaScript

Published on June 30, 2020 · Updated on August 27, 2021

The 2015 edition of the ECMAScript specification (ES6) added template literals to the JavaScript language. Template literals are a new form of making strings in JavaScript that add a lot of powerful new capabilities, such as creating multi-line strings, using placeholders to embed expressions in a string, and parsing dynamic string expressions with tagged template literals. In this article, you will go over the differences between single/double-quoted strings and template literals.

// Tutorial //

Understanding Arrow Functions in JavaScript

Published on July 31, 2020 · Updated on August 27, 2021

Arrow functions are a new way to write anonymous function expressions in JavaScript, and are similar to lambda functions in some other programming languages like Python. They differ from traditional functions in the way their scope is determined and how their syntax is expressed, and are particularly useful when passing a function as a parameter to a higher-order function, like an array iterator method. In this article, you will find examples of arrow function behavior and syntax.

// Tutorial //

Understanding the Event Loop, Callbacks, Promises, and Async/Await in JavaScript

Published on September 10, 2020 · Updated on August 27, 2021

In order to avoid blocking code in JavaScript development, asynchronous coding techniques must be used for operations that take a long time, such as network requests made from Web APIs like Fetch. This article will cover asynchronous programming fundamentals, teaching you about the event loop, the original way of dealing with asynchronous behavior through callbacks, the updated ECMAScript 2015 (ES6) addition of promises, and the modern practice of using async/await.

// Tutorial //

Understanding Modules and Import and Export Statements in JavaScript

Published on October 23, 2020 · Updated on August 27, 2021

As the importance of JavaScript in web development grows, there is a bigger need to use third-party code for common tasks, to break up code into modular files, and to avoid polluting the global namespace. To account for this, ECMAScript 2015 (ES6) introduced modules to the JavaScript language, which allowed for the use of import and export statements. In this tutorial, you will learn what a JavaScript module is and how to use import and export to organize your code.

Check out all our Tutorial Series

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.

Sign up