Learnitweb

Category: JavaScript tutorial

  • Object.freeze() in JavaScript

    1. Introduction In this tutorial, we’ll discuss freeze() method of Object. The freeze() method freezes an object. Frozen object here means: new properties can not be added to a frozen object. existing properties can not be removed. values of existing properties of a frozen object can not changed. the prototype of a frozen object can…

  • Introduction to JavaScript Promise

    1. Introduction Suppose you ordered a burger in a restaurant. The cashier will take your order and will promise you that the burger will be delivered. After some time once the burger is available, your burger will be delivered. It is also possible that the burger will not be delivered due to some problem. The…

  • JavaScript Optional Chaining Operator (?.)

    1. Introduction The optional chaining operator (?.) enables you to read the property within a chain of connected objects without specifically checking each reference in the chain for null or undefined. The ?. operator short-circuits the chain and returns undefined if any reference in the chain is nullish (null or undefined). The behavior of ?.…

  • 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…