How to store data to DOM?

Shubham Vora
Updated on 15-Mar-2026 23:19:01

2K+ Views

Storing data in the DOM means keeping data associated with HTML elements or in JavaScript variables that can be accessed later. This is useful for maintaining application state, form data, or temporary values without making server requests. In vanilla JavaScript, we can store data in objects or use element properties. jQuery provides the data() method for attaching data to specific DOM elements. Let's explore both approaches. Using JavaScript Objects to Store Data The most common approach is creating JavaScript objects to hold data. This keeps information organized and easily accessible. Syntax let dataObj = ... Read More

JavaScript Program for Clockwise rotation of Linked List

Prabhdeep Singh
Updated on 15-Mar-2026 23:19:01

521 Views

In JavaScript, a clockwise rotation of a linked list moves the last k elements to the front. This operation is commonly used in data structure manipulations and algorithm problems. Given a linked list and a rotation count k, we need to move the last k nodes to the beginning. For example, rotating 1 → 2 → 3 → 4 → 5 clockwise by 2 positions results in 4 → 5 → 1 → 2 → 3. Structure of Linked List First, we'll create a Node class and helper functions to build and display the linked list: ... Read More

Javascript Program for Range Queries for Frequencies of array elements

Prabhdeep Singh
Updated on 15-Mar-2026 23:19:01

273 Views

We are given an array that will contain integers and another array will be given that will contain the queries and each query represents the range that we are given by the leftmost and the rightmost index in the array and an element. For that range or the subarray, we have to find the frequency of the given element present in that range. The frequency of the elements means that we have to tell for each integer present in that range how many times it occurs. For example − If, the given array is: [5, 2, 5, 3, ... Read More

How to store JavaScript functions in a queue and execute in that order?

Shubham Vora
Updated on 15-Mar-2026 23:19:01

824 Views

In JavaScript, you may need to store functions in a queue and execute them in a specific order. Since JavaScript doesn't have a built-in queue data structure, we can use arrays with push() to enqueue functions and shift() to dequeue them. This pattern is useful for managing asynchronous operations, implementing task schedulers, or controlling execution flow in applications. Basic Queue Operations A function queue uses these core operations: Enqueue: Add function to the end using push() Dequeue: Remove and execute function from the front using shift() Execute: Call functions in First-In-First-Out (FIFO) order ... Read More

JavaScript program for Sort the given matrix

Aishwarya Mani Tripathi
Updated on 15-Mar-2026 23:19:01

415 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

How to Filter Object by Values in Lodash?

AYUSH MISHRA
Updated on 15-Mar-2026 23:19:01

5K+ Views

Sometimes we are given an object and we want to extract only the key-value pairs that meet certain criteria. In this article, we are going to discuss how we can filter objects by values in Lodash. Prerequisite Lodash: Lodash is a popular JavaScript library used to deal with a variety of functions such as arrays, objects, strings, and more. Install Lodash We can install the Lodash library in the project by adding it via CDN or npm using the following command: npm install lodash Approaches to Filter Object ... Read More

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

Aishwarya Mani Tripathi
Updated on 15-Mar-2026 23:19:01

306 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

How to Convert URL Parameters to JSON in JavaScript?

Pankaj Kumar Bind
Updated on 15-Mar-2026 23:19:01

2K+ Views

When working with URLs you will often encounter query parameters that add additional information to the base URL. It may be helpful for developers whenever they need to convert these URL parameters to JSON format, especially for reading and manipulating data. Here we will explore different methods to convert URL parameters to a JSON format in JavaScript including built-in methods and custom solutions using split, reduce, and regular expressions. Understanding URL Parameters URL parameters (query string) follow the ? character in a URL, with each key-value pair separated by &. Here's an example URL: https://example.com/page?name=Pankaj&age=20&city=Surat ... Read More

JavaScript Program for Removing Duplicates From An Unsorted Linked List

Prabhdeep Singh
Updated on 15-Mar-2026 23:19:01

348 Views

The linked list is a linear data structure that consists of nodes, and each node is stored in memory in a non-contiguous manner. Nodes are connected by storing the address of the next node. We are given a linked list that will contain some integers in a random manner and not in a sorted manner. The task is to find the elements of the linked list which are repeated and we have to remove the duplicated ones. In this problem, we will keep the first copy of the elements of the linked list and remove the elements which are ... Read More

JavaScript Program to Check if it is possible to make array increasing or decreasing by rotating the array

Prabhdeep Singh
Updated on 15-Mar-2026 23:19:01

259 Views

Rotation of the array means to assume the array as a circular array and rotate the elements of the array to either their left or right direction by one index at each rotation and the element at one end may take the value present at another end. An Increasing array means that each element will be greater than or equal to its previous element and decreasing array means each element will be less than or equal to the previous element. In this problem, we are given an array and we can rotate the array in either the left or ... Read More

Advertisements