Javascript Articles

Page 14 of 534

How to change the href value of tag after clicking on button using JavaScript?

Gungi Mahesh
Gungi Mahesh
Updated on 15-Mar-2026 11K+ Views

The href attribute specifies the link's destination, which can be a URL or an anchor point within the same document. Changing the href attribute value allows us to dynamically update the destination of the link, which can be useful in creating interactive web applications. The tag (anchor tag) is used to create hyperlinks in HTML, linking to other web pages or specific locations within the same document. By combining JavaScript with HTML elements, we can modify these links dynamically based on user interactions. In this article, we'll explore how to change the href value of an anchor ...

Read More

Explain Chosen and Select2 with Examples

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 1K+ Views

Select2 and Chosen are popular jQuery plugins that enhance HTML select boxes with improved styling, search capabilities, and user-friendly features. Both plugins work with single and multiple select elements, making form interactions more intuitive. Chosen Plugin Chosen is a JavaScript plugin that transforms standard select boxes into user-friendly dropdown interfaces. It's available for both jQuery and Prototype frameworks. Key Features of Chosen User-friendly Interface Users can search by typing instead of scrolling through long lists. Matching is instant, and non-matching options are filtered out automatically. Progressive Enhancement Chosen gracefully degrades to standard HTML select elements ...

Read More

Explain Implement a Memoization Helper Function

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 442 Views

Memoization is a programming technique that improves function performance by caching previously calculated results. When a function is called with the same arguments, instead of recalculating, it returns the cached result, significantly reducing execution time for expensive operations. What is Memoization? Memoization works by storing function results in a cache (usually an object or Map). When the function is called again with identical parameters, it checks the cache first. If the result exists, it returns the cached value; otherwise, it calculates the result and stores it for future use. Basic Example: Slow Function Without Memoization Let's ...

Read More

JavaScript Program for Clockwise rotation of Linked List

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 505 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 to Check whether all the rotations of a given number are greater than or equal to the given number or not

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 238 Views

In this article, we will go through a JavaScript program to check whether all the rotations of a given number are greater than or equal to the given number or not. We will write an algorithm and explain every step that what we are doing. The time complexity of the code that is going to discuss will be optimistic and space complexity will all be improved from one code to another. Introduction to Problem In the problem, we are given a number and we have to check for each rotation whether they all are greater than the current ...

Read More

JavaScript Program for Count Primes in Ranges

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 4K+ Views

Prime numbers are numbers that have exactly two perfect divisors (1 and themselves). This article explores multiple methods to count prime numbers in a given range using JavaScript. We'll start with basic approaches and then optimize using the Sieve of Eratosthenes algorithm for better performance. Method 1: Direct Approach (O(N) per number) This method counts all divisors of a number. If exactly 2 divisors exist, the number is prime. function isPrime(number) { var count = 0; for (var i = 1; i

Read More

JavaScript Program for Finding a Triplet from Three Linked Lists with a Sum Equal to a Given Number

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 234 Views

In this article, we are going to implement a JavaScript program for finding a triplet from three linked lists with a sum equal to a given number. This problem is a variation of the standard three-sum problem but applied to linked lists instead of arrays. Problem Statement Given three linked lists and a target number, we need to find if there exists a triplet (one element from each list) whose sum equals the target number. If such a triplet exists, return true; otherwise, return false. Example: Target: 10 List 1: 1 → 2 → 3 ...

Read More

How to convert Title to URL Slug using JavaScript?

Aman Gupta
Aman Gupta
Updated on 15-Mar-2026 1K+ Views

Overview The conversion of a title to URL Slug is also known as "Slugify" a title. A URL Slug refers to a descriptive, readable identifier attached to a page's URL that describes the content. Converting titles to URL-friendly slugs involves using JavaScript string methods like toLowerCase(), replace(), and trim(). Algorithm Step 1 − Create HTML input elements with IDs "title" and "urlSlug" for input and output, plus a button with onclick event. Step 2 − Create a convert() function to handle the transformation. Step 3 − Get the title value using document.getElementById("title").value. Step 4 − Convert to lowercase ...

Read More

JavaScript Program for the Least Frequent Element in an Array

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 785 Views

In this program, we are given an array of integers and need to return the element that appears the least number of times. If multiple elements have the same minimum frequency, we can return any one of them. Problem Statement Given an array with duplicate numbers, we need to count the occurrence of each element and return the one with the least frequency. If multiple elements have the same minimum frequency, any one can be returned. Example 1: Input: [1, 3, 3, 5, 5, 4, 4, 4] Output: 1 Explanation: 1 appears 1 time, 3 ...

Read More

JavaScript Program for Longest Subsequence of a Number having Same Left and Right Rotation

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 277 Views

We will implement a code to find the longest subsequence of a given number that has the same left and right rotation in JavaScript. Left rotation moves the leftmost digit to the rightmost position, while right rotation moves the rightmost digit to the leftmost position. Understanding the Problem Given a number, we need to find a subsequence (formed by deleting some digits) where left and right rotations produce the same result. For example: Single digit sequences always have equal rotations: 1, 2, 3 Two identical digits: 11, 22, 33 Alternating patterns of even length: 1010, 2323, ...

Read More
Showing 131–140 of 5,340 articles
« Prev 1 12 13 14 15 16 534 Next »
Advertisements