Found 6710 Articles for Javascript

JavaScript Program for Pairwise Swapping Elements of a Given Linked List

Aishwarya Mani Tripathi
Updated on 02-May-2023 17:43:24

223 Views

In this tutorial, we are going to learn about a JavaScript Program for Pairwise Swapping Elements of a Given Linked List. One common operation on linked lists is swapping adjacent elements in pairs. This operation can be useful in various scenarios, such as reorganizing data, rearranging elements in a specific order, or optimizing certain algorithms. Also, we will focus on solving the problem of pairwise swapping elements in a given linked list using JavaScript. We will provide a step-by-step approach to implementing the algorithm, explaining the logic and code behind it. By the end of this tutorial, you will have ... Read More

JavaScript Program for Pairs such that one is a power multiple of other

Aishwarya Mani Tripathi
Updated on 02-May-2023 17:41:58

156 Views

JavaScript Program for pairs such that one is a power multiple of the other is a problem that involves finding pairs of numbers such that one number is a power multiple of the other. In this tutorial, we will be discussing how to write a JavaScript program to solve this problem. We will be exploring various approaches and algorithms to find these pairs efficiently. Additionally, we will also be discussing the time and space complexity of these algorithms to provide a comprehensive understanding of the topic. So, let's dive in and learn how to write a JavaScript program to find ... Read More

JavaScript Program for Number of unique triplets whose XOR is zero

Aishwarya Mani Tripathi
Updated on 02-May-2023 17:39:10

412 Views

JavaScript Program for the Number of unique triplets whose XOR is zero is a common programming problem that requires finding the number of unique triplets in a given array whose XOR is equal to zero. The XOR operation is a bitwise operator that takes two bits and returns 1 if the bits are different, and 0 if they are the same. In this problem, we need to find all possible combinations of three numbers in the array, where the XOR of the triplet is zero. This problem can be solved using various approaches, including brute force, hashing, and sorting. In ... Read More

JavaScript Program for Number of Local Extrema in an Array

Ravi Ranjan
Updated on 09-Jun-2025 19:15:46

240 Views

JavaScript Program for the Number of local extrema in an array is a common problem in the field of computer science and data analysis. Local extrema are the peaks and valleys in a sequence of numbers. In this article we are having two arrays, our task is to write a Javascript program for number of local extrema in an array. Example Input: arr1 = [1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1]; First local extrema: 3, {2 < 3 > 2} Second local extrema: 1, {2 > 1 < 4} Third local ... Read More

JavaScript Program for Mirror of Matrix Across Diagonal

Ravi Ranjan
Updated on 06-Jun-2025 19:14:12

392 Views

To write a javascript program for mirror of matrix across diagonal, we will be discussing two approaches with their code example and explanation of code. In this article we are having a 2D matrix. Our task is to write a JavaScript program for mirror of matrix across diagonal. Example Input: matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Output: [[1, 4, 7], [2, 5, 8], [3, 6, 9]] Approaches ... Read More

JavaScript program for Minimum Product Subset of an Array

Aishwarya Mani Tripathi
Updated on 02-May-2023 17:09:03

245 Views

JavaScript Program for Minimum product subset of an array is a common problem that arises in the field of computer science and programming. The problem statement requires us to find the minimum product that can be obtained from any subset of the given array. A minimum product subset of an array is a subset of array elements that yields the smallest possible product. Several algorithms are available for identifying this subset, including dynamic programming, greedy algorithms, and branch and bound. The selection of the algorithm is determined by the particular constraints and specifications of the problem at hand. In this ... Read More

Using data in JSON format in Snack

Saba Hilal
Updated on 02-May-2023 14:43:09

699 Views

There are lots of ways to use data with apps made with Snack Expo. Sometimes the data is stored as JSON, that mean JavaScript Object Notation. In this format, the data can be stored easily as Key-Value pairs and can also be converted to a CSV file. In this article, using javascript on Snack, the methods to use JSON data are specified. In example 1, the method to read this data and to display it as a table is given. In the second example, the methods of saving the JSON data as a CSV file and to download it, is ... Read More

What is tree shaking in JavaScript?

Shubham Vora
Updated on 24-Apr-2023 17:07:18

316 Views

What is Tree Shaking? If you are an experienced JavaScript developer, you may hear about tree shaking. It is a common technique to remove unused codes from the application and also, and it removes unused imports from the application. Here, the ‘Tree shaking’ term is introduced by shaking a tree, removing unnecessary branches of the code, and keeping the required code in the final bundle. Basically, tree shaking is used to eliminate the dead or unused code. Why do we Require Tree Shaking? As we have seen in the above part of the tutorial, tree shaking is used to remove ... Read More

What is server-sent events in JavaScript?

Shubham Vora
Updated on 24-Apr-2023 17:06:31

1K+ Views

What is Server-sent Events in JavaScript? In JavaScript, server-sent events (SSE) enable the server to send data to the client. The client require to establish a connection with the server to get data from the server. The server-sent events are similar to the WebSocket as it also establishes a connection between the client and server, and it is useful to send data on both sides. But server-sent events allow unidirectional communication, which means the server can send data to the client, but the client can’t send data to the server. Let’s build a real-time React and Node application to use ... Read More

What are the events available for server sent events in JavaScript?

Shubham Vora
Updated on 24-Apr-2023 17:05:06

398 Views

The server-sent events allow developers to open a connection between the server and the client and send data from the server to the client. Basically, it is a one-way communication, which means we can send data from the server to the client but not from the client to the server. Here, we will discuss all events available for the server-sent events in JavaScript. Events Available for Server-sent Events in JavaScript There is a total of 4 different events available for server-sent events in JavaScript. ‘onopen’ − The ‘open’ event fires when the connection between the client and server is ... Read More

Advertisements