Javascript Articles

Page 19 of 534

JavaScript program for Shortest Un-Ordered SubarrayJavaScript program for Shortest Un-Ordered Subarray

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 185 Views

The problem statement requires finding the shortest un-ordered subarray in an array of integers. In other words, we need to identify the smallest subarray in which the elements are not sorted in ascending or descending order. This problem can be solved through various approaches, but in this article, we will discuss a simple and efficient solution using JavaScript. So first we will start by defining what an un-ordered Subarray is, then understand the problem statement in detail and then proceed to explain the step-by-step solution using examples and code snippets. By the end of this article, you will have ...

Read More

Explain about IIFEs in JavaScript

Nikesh Jagsish Malik
Nikesh Jagsish Malik
Updated on 15-Mar-2026 420 Views

In the world of JavaScript, there are various techniques and patterns that developers use to write efficient, maintainable code. One such powerful programming technique is the Immediately Invoked Function Expression (IIFE). In this article, we'll dive into IIFEs, their benefits, and how to implement them using different approaches. We'll also explore some practical examples to help you understand their applications in real-world scenarios. What is an IIFE? An IIFE is a function expression that is executed immediately after its definition. It creates its own scope, preventing variables from polluting the global namespace. Syntax (function() { ...

Read More

JavaScript program for Sort the given matrix

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 392 Views

Sorting a given matrix using JavaScript is a fundamental operation in programming. Sorting is the process of arranging the elements of a collection or matrix in a particular order. It is essential to make searching and other operations more efficient. In this article, we will discuss how to sort a given matrix using the JavaScript programming language. Problem Statement Given an n x n matrix, we need to sort all elements so that the matrix follows "strict order" - each row is sorted in ascending order, and for any row i where 1 ≤ i ≤ n-1, ...

Read More

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

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 295 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 ...

Read More

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

Nikesh Jagsish Malik
Nikesh Jagsish Malik
Updated on 15-Mar-2026 645 Views

Finding years where January 1st falls on a Sunday is useful for planning events, scheduling, and calendar calculations. JavaScript's Date object makes this straightforward by providing methods to determine the day of the week. How It Works The approach uses JavaScript's Date constructor and getDay() method. The getDay() method returns 0 for Sunday, 1 for Monday, and so on. We iterate through a range of years, create a Date object for January 1st of each year, and check if it's a Sunday. Method 1: Direct Sunday Check This method directly checks if getDay() returns 0 (Sunday): ...

Read More

How do you make synchronous HTTP request in JavaScript?

Nikesh Jagsish Malik
Nikesh Jagsish Malik
Updated on 15-Mar-2026 9K+ Views

Making synchronous HTTP requests in JavaScript blocks code execution until the response arrives. While generally discouraged, certain scenarios may require this approach. This article explores methods to create synchronous HTTP requests in JavaScript. Why Synchronous Requests? Synchronous requests pause execution until completion, which can freeze the browser. However, they're sometimes needed for: Critical data required before proceeding Sequential API calls with dependencies Legacy code compatibility Algorithm The basic steps for making synchronous HTTP requests: Create an HTTP request object ...

Read More

How to Send Axios Delete to the Backend ReactJS in JavaScript

Nikesh Jagsish Malik
Nikesh Jagsish Malik
Updated on 15-Mar-2026 4K+ Views

Sending DELETE requests to a backend is a common requirement in React applications. Axios provides multiple ways to handle DELETE operations, making it easy to remove data from your server. What is Axios DELETE? Axios DELETE is an HTTP method used to remove resources from a server. In React applications, you'll typically use it to delete user records, posts, comments, or any other data that needs to be removed from your backend database. Algorithm Here are the steps to send an Axios DELETE request in React: Import Axios − Include the Axios library in ...

Read More

How to concatenate regex literals in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

Regular expressions (regex literals) are patterns used to match character combinations in strings. Sometimes, you need to combine multiple regex patterns into a single expression. Unlike strings, regex literals cannot be concatenated directly with the '+' operator. To concatenate regex literals, you must extract their source patterns and flags, combine them properly, and create a new RegExp object. Syntax Follow this approach to concatenate regex literals: let allFlags = regex1.flags + regex2.flags; let uniqueFlags = [...new Set(allFlags.split(''))].join(''); let combined = new RegExp(regex1.source + regex2.source, uniqueFlags); This extracts the source patterns and flags from ...

Read More

Find the OR and AND of Array elements using JavaScript

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 203 Views

In JavaScript, we can use the '&&' operator to perform the AND operation between two elements and the '||' operator to perform OR operation between two elements. Here, we will learn to perform OR and AND operations between every element of the array using different approaches. Use the for Loop We can use the for loop to iterate through the array elements and perform OR or AND operations with all array elements. Syntax Users can follow the syntax below to use the for loop to take OR or AND operation of every element. ...

Read More

Finding the time elapsed in JavaScript

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 23K+ Views

Finding time elapsed in JavaScript is essential for performance monitoring, measuring execution time, and tracking user interactions. JavaScript provides several built-in methods to calculate time differences accurately. In this tutorial, we'll explore three different approaches: the Date() object for general time calculations, console.time() for debugging, and performance.now() for high-precision measurements. Using the Date() Object The Date() constructor returns the current timestamp in milliseconds since January 1, 1970 (Unix epoch). We can calculate elapsed time by finding the difference between two timestamps. Syntax let startTime = new Date(); let endTime = new Date(); let timeElapsed ...

Read More
Showing 181–190 of 5,340 articles
« Prev 1 17 18 19 20 21 534 Next »
Advertisements