Found 6710 Articles for Javascript

How to concatenate regex literals in JavaScript?

Shubham Vora
Updated on 19-Apr-2023 15:24:09

2K+ Views

The regex literals are regular expressions, a sequence of characters to match the strings. Sometimes, developers require to combine regular expressions. However, a regular expression is also one type of string, but we can’t concat them like a string using the ‘+’ operator. So, we first require to get flags from both regular expressions. After that, we must filter all unique flags and create a new Regex after combining multiple Regex literals. Syntax Users can follow the syntax below to concatenate regex literals in JavaScript. let allFlags = regex1.flags + regex2.flags; let uniqueFlags = new Set(allFlags.split('')); allFlags = [...uniqueFlags].join(''); let ... Read More

How to load CSS files using JavaScript?

Saba Hilal
Updated on 18-Apr-2023 15:23:15

6K+ Views

Sometimes, the task is change the page themes and to use different CSS files on the same page content. In such tasks the need is to fetch a CSS and load it dynamically while selecting a theme. In this case the CSS file has to be accessed, loaded and even selected through a javascript program. Using HTML and javascript code this process of loading the CSS file is demonstrated in this article. This is shown by using two different examples. In the first example, a CSS file is selected on the windows load event. In the second example, two buttons ... Read More

How to Send Axios Delete to the Backend ReactJS in JavaScript

Nikesh Jagsish Malik
Updated on 17-Apr-2023 16:06:15

4K+ Views

What is Send Axios Delete? Deleting data from a backend using ReactJS and Axios can be a challenging task. However, with the right approach and knowledge, you can easily achieve this task. In this article, we'll explore how to send an Axios delete request to the backend in ReactJS using JavaScript. We'll cover two different approaches with code and explanations, as well as two working examples. So, let's dive in! Algorithm To commence our discourse, it is of utmost importance to apprehend the procedure for transmitting an Axios obliteration entreaty to the back end when utilizing ReactJS. Here are the ... Read More

How do you make synchronous HTTP request in JavaScript?

Nikesh Jagsish Malik
Updated on 17-Apr-2023 16:01:26

9K+ Views

In the current digital terrain, the act of making HTTP requests is a vital component in transmitting and receiving data between the client and server. Asynchronous requests have gained prevalence as they provide a non-blocking experience, which ultimately enhances the overall user experience. Nevertheless, there are certain situations where synchronous HTTP requests may prove necessary or preferable. In the ensuing narrative, we shall delve into the algorithm for creating synchronous HTTP requests using JavaScript. We will also explore two distinct approaches with their corresponding code explanations and practical applications. Algorithm To initiate synchronous HTTP requests in JavaScript, one must execute ... Read More

Find quotient and remainder by dividing an integer in JavaScript

Nikesh Jagsish Malik
Updated on 17-Apr-2023 15:56:20

2K+ Views

Dividing an integer is a mathematical operation where we divide a number into two parts, the quotient, and the remainder. In JavaScript, we use this operation to perform various calculations and to get the desired result. In this article, we will discuss how to find the quotient and remainder by dividing an integer in JavaScript. Algorithm The algorithm for dividing an integer in JavaScript is straightforward. We divide the number into two parts, the quotient, and the remainder. The quotient is the result of the division, and the remainder is the part of the number that is left over after ... Read More

Find 1st January be Sunday between a range of years in JavaScript?

Nikesh Jagsish Malik
Updated on 17-Apr-2023 15:55:31

549 Views

It's always important to know when the 1st January falls on a Sunday in a range of years. This information can be used for various purposes, such as scheduling events, managing projects, and more. The purpose of this article is to help you find the 1st January falling on Sunday in a range of years in JavaScript. Algorithm The algorithm to find the 1st January falling on Sunday between a range of years involves several steps. The first step is to calculate the number of days between the current year and the year you want to find the 1st January ... Read More

JavaScript Program for Two Pointers Technique

Ravi Ranjan
Updated on 06-Jun-2025 12:33:05

2K+ Views

In this article we are given a sorted array, our task is to find if there exists any pair of elements such that their sum is equal to a given number. Users must be familiar with array, loop and nested loops, and if/else statement. Two Pointers Technique Two pointers technique is a commonly used algorithmic approach to solve various problems that require linear time complexity. This technique is used to find a solution for problems that involve searching, sorting, or manipulating arrays, strings, or linked lists. In this article, we are going to solve the pair sum problem using brute ... Read More

JavaScript Program for the Third Largest Element in an Array of Distinct Elements

Ravi Ranjan
Updated on 06-Jun-2025 19:17:02

785 Views

For the third largest element in an array of distinct elements, we will discuss three different approaches. We will improve efficiency with each approach and discuss their complexities. In this article we are having an array of distinct elements, our task is to find third largest element in an array of distinct elements in Javascript. Users must be familiar with array, loops and conditional statement. Example Input: arr = [2, 5, 8, 1, 4, 10, 7] => Highest: 10, second highest: 8, third highest: 7 Output: 7 Approaches for Third Largest Element in Array ... Read More

JavaScript program for Swapping Nodes in A Linked List Without Swapping Data

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:50:02

356 Views

JavaScript program for Swapping Nodes in A Linked List Without Swapping Data is a familiar problem in web development that involves rearranging the order of nodes in a linked list. A linked list is a data structure that consists of nodes, each containing a piece of data and a reference to the next node in the list. In this article, we will learn a complete tutorial about swapping nodes in a linked list without swapping data using JavaScript. So let’s get started by defining swapping nodes first and then we move ahead in this tutorial. So, Keep learning! Swapping Nodes ... Read More

JavaScript Program for Sorting a Linked List of 0s, 1s, And 2s

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:47:44

226 Views

In this tutorial, we will learn the JavaScript program for sorting a linked list of 0s, 1s, and 2s. Sorting algorithms are essential for any programming language, and JavaScript is no exception. Sorting a linked list of 0s, 1s, and 2s is a common problem that developers encounter in coding interviews and real-world applications. So, let's dive in and explore how to sort a linked list of 0s, 1s, and 2s using JavaScript programming. What is sorting? Sorting is the process of arranging elements in a specific order, either ascending or descending. It is a fundamental operation in computer science ... Read More

Advertisements