Learnitweb

Category: JavaScript tutorial

  • typeof operator in JavaScript

    1. Introduction The typeof operator returns the type of the object or primitive operand. The return type of typeof is string. The typeof operator is very helpful but is not suitable for all situations. The typeof operator returns object for many objects so it can not be used precisely in the code to check the…

  • Arrow function expressions in JavaScript

    1. Introduction An arrow function expression is a short and compact form of writing traditional function expression with some limitations. It is not a complete replacement of traditional function expression and is not suited for all situations. Let us understand this with an example. Following is the traditional anonymous function: The equivalent arrow function is:…

  • JavaScript apply() method

    1. Introduction The apply() method calls a function. While calling this method you can provide this argument and arguments as an array. The apply() method is identical to that of call() with difference that arguments are passed to call() as separate arguments whereas arguments are passed to apply() as an array. Following are valid versions…

  • JavaScript call() method

    1. Introduction The call() method calls a function. While calling this method you can provide this argument and other arguments. All the following are valid versions of call() method: thisArgument is the optional argument which is used as this. arg1….argN are the optional arguments provided to the function. 2. Examples of call() Example 1: Using…

  • Inheritance and the prototype chain in JavaScript

    1. Introduction In this tutorial, we’ll discuss inheritance and the prototype chain in JavaScript. Prototype chain is one of the most confusing topic of JavaScript and is the most important concept to know in JavaScript as many cool features of JavaScript are based on prototypal inheritance. In nature, you’ll see inheritance everywhere. Every man inherits…

  • Nullish coalescing operator ‘??’

    1. Introduction In this tutorial, we’ll discuss nullish coalescing operator. Nullish coalescing operator is written as double question marks (??). The syntax of nullish coalescing operator is: Nullish coalescing operator works in the following manner: return leftExpression if not null or undefined. return rightExpression if null or undefined. nullish coalescing operator is short and convenient…

  • null in JavaScript

    1. Introduction null in JavaScript is an object which represents the intentional absence of value. null is a primitive value in JavaScript. null is treated as falsy for boolean operations. null is different from undefined which also means absence of value. Variables which are declared but not assigned any value are initialized to default value…

  • undefined in JavaScript

    1. Introduction In this tutorial, we’ll discuss undefined in JavaScript. This concept is little bit different from other popular languages like Java. In Java null is used to show absence of value. In JavaScript, people are confused about null and undefined as both look like absence of value. In this tutorial, we’ll try to explain…

  • Symbol in JavaScript

    1. Introduction In this tutorial, we’ll discuss in detail about a primitive type introduced in ECMAScript 6 – Symbol. The JavaScript already had five primitive types: string, number, boolean, null, and undefined before Symbol was introduced. In this tutorial, we’ll discuss Symbol and how to create a Symbol. We’ll also discuss about Symbol properties. But…

  • Destructuring assignment in JavaScript

    1. Introduction While working with arrays and objects sometimes we need to pull out values and assign it to distinct variables. The destructuring syntax makes it easy to do this with less code. Without destructuring it may require duplicate code. For example: You can observe, there will be repetitive code if there are more properties.…