Category: JavaScript Tutorial

python tutorials and learn python

Created with Sketch.

JavaScript Promise.all()

JavaScript Promise.all() Summary: in this tutorial, you will learn how to use the Promise.all() static method to aggregate results from multiple asynchronous operations. Introduction to the JavaScript Promise.all() method The Promise.all() static method takes an iterable of promises: Promise.all(iterable); Code language: JavaScript (javascript) The Promise.all() method returns a single promise that resolves when all the…
Read more

Promise Chaining

Promise Chaining Summary: in this tutorial, you will learn about the JavaScript promise chaining pattern that chains the promises to execute asynchronous operations in sequence. Introduction to the JavaScript promise chaining Sometimes, you want to execute two or more related asynchronous operations, where the next operation starts with the result from the previous step. For…
Read more

JavaScript Promises

JavaScript Promises Summary: in this tutorial, you will learn about JavaScript promises and how to use them effectively. Why JavaScript promises The following example defines a function getUsers() that returns a list of user objects: function getUsers() { return [ { username: ‘john’, email: ‘john@test.com’ }, { username: ‘jane’, email: ‘jane@test.com’ }, ]; } Code…
Read more

JavaScript Callbacks

JavaScript Callbacks Summary: in this tutorial, you will learn about JavaScript callback functions including synchronous and asynchronous callbacks. What are callbacks In JavaScript, functions are first-class citizens. Therefore, you can pass a function to another function as an argument. By definition, a callback is a function that you pass into another function as an argument…
Read more

JavaScript Rest Parameters

JavaScript Rest Parameters Summary: in this tutorial, you will learn how to use the JavaScript rest parameters to gather parameters and put them all in an array. Introduction to JavaScript rest parameters ES6 provides a new kind of parameter so-called rest parameter that has a prefix of three dots (…). A rest parameter allows you to represent an…
Read more

When You Should Not Use Arrow Functions

When You Should Not Use Arrow Functions Summary: in this tutorial, you will learn when you should not use the arrow functions in ES6. An arrow function doesn’t have its own this value and the arguments object. Therefore, you should not use it as an event handler, a method of an object literal, a prototype…
Read more

An Introduction to JavaScript Arrow Functions

An Introduction to JavaScript Arrow Functions Summary: in this tutorial, you will learn how to use the JavaScript arrow function to write more concise code for function expressions. Introduction to JavaScript arrow functions ES6 arrow functions provide you with an alternative way to write a shorter syntax compared to the function expression. The following example…
Read more

Returning Multiple Values from a Function

Returning Multiple Values from a Function Summary: in this tutorial, you will learn to define JavaScript functions that return multiple values. JavaScript functions can return a single value. To return multiple values from a function, you can pack the return values as elements of an array or as properties of an object. Returning multiple values…
Read more

JavaScript Immediately Invoked Function Expression

JavaScript Immediately Invoked Function Expression Summary: in this tutorial, you will learn about JavaScript immediately invoked function expressions (IIFE). TL;DR A JavaScript immediately invoked function expression is a function defined as an expression and executed immediately after creation. The following shows the syntax of defining an immediately invoked function expression: (function(){ //… })(); Code language:…
Read more

JavaScript Closures

JavaScript Closures Summary: in this tutorial, you will learn about JavaScript closures and how to use closures in your code more effectively. Introduction to JavaScript closures In JavaScript, a closure is a function that references variables in the outer scope from its inner scope. The closure preserves the outer scope inside its inner scope. To…
Read more