Blog

python tutorials and learn python

Created with Sketch.

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

JavaScript bind() Method

JavaScript bind() Method Summary: in this tutorial, you will learn about the JavaScript bind() method and know how to use it effectively. Introduction to JavaScript bind() method The bind() method returns a new function, when invoked, has its this sets to a specific value. The following illustrates the syntax of the bind() method: fn.bind(thisArg[, arg1[,…
Read more

JavaScript apply() method

JavaScript apply() method Summary: in this tutorial, you’ll learn about the JavaScript apply() method of the Function type and how to use it effectively. Introduction to the JavaScript apply() method The Function.prototype.apply() method allows you to call a function with a given this value and arguments provided as an array. Here is the syntax of…
Read more