Learnitweb

Category: JavaScript tutorial

  • Currying in JavaScript

    1. Introduction Currying is a functional programming technique where a function that takes multiple arguments is transformed into a series of functions, each taking a single argument. This allows you to apply arguments to a function one at a time. In JavaScript, currying allows you to partially apply a function. In simple terms, you can…

  • Array.prototype.slice() method

    1. Introduction The slice() method creates a shallow copy of a specified section of an array, returning it as a new array object. The selection is based on the indices provided as start and end parameters, with end being exclusive. This operation does not alter the original array. 2. Example 3. Using negative indices In…

  • A07:2021 – Identification and Authentication Failures

    1. Overview Identification and Authentication Failures occur when mechanisms designed to verify the identity of users are improperly implemented, bypassed, or vulnerable to attacks. These vulnerabilities can lead to unauthorized access, impersonation, or account compromise. Confirmation of the user’s identity, authentication, and session management is critical to protect against authentication-related attacks. There may be authentication…

  • Scope in JavaScript

    1. Introduction The scope is a general concept in the field of computer science that refers to the parts of the program where a particular variable, function, etc., can be accessed. In other words, the scope of an identifier (variable, function, etc.) is the part of a program where it is visible or can be…

  • Execution Context in JavaScript

    1. Introduction In JavaScript, code is executed and is related to two main types of executions contexts. In this tutorial, we’ll discuss these two execution contexts: There is third type of execution context that is created for the code inside the eval function. Since the use of eval function is discouraged due to security concerns,…

  • HashSet in Java

    1. Introduction In this tutorial we’ll discuss HashSet class of the Java Collections Framework. HashSet class is in java.util package in java.base module. HashSet class implements the Set interface, backed by a hash table (actually a HashMap instance). Following are the features of HashSet: Here is an example of HashSet: Output 2. Creating HashSet HashSet…

  • Java carrier thread example

    1. Introduction In this short tutorial, we’ll see an example of carrier thread in Java. We’ll see with an example that carrier threads work on different tasks in case of virtual threads. 2. Example of Platform thread working on tasks In this example, we are creating and starting platform threads. We are using sleep() method…

  • Create unmodifiable copy using copyOf method

    1. Introduction In Java 10, the Set.copyOf, List.copyOf, Map.copyOf static factory methods provide a convenient way to create unmodifiable collections (Set, List and Map). A collection is considered as unmodifiable if elements cannot be added, modified or removed. An unmodifiable collection hold the same data as long as the reference exists to the collection. The…

  • Web document origin

    1. Introduction In this tutorial, we’ll discuss what is a web document’s origin. Understanding a document’s origin is important while discussing other topics like CORS error and Window.localStorage. A document’s origin is defined by following three things of the URL used to access it: 2. Examples Following are same origin: Following are different origin:

  • WeakSet in JavaScript

    1. Introduction A WeakSet is a collection of unique objects and references to objects in a WeakSet are held weakly. The term weakly here means that if no other references to an object stored in WeakSet exist, those objects can be garbage collected. WeakSet can contain only objects. Since objects of WeakSet are held weakly…