Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
JavaScript Program for Printing Reverse of a Linked List Without Actually Reversing
Linked lists are linear data structures with their memory not being in a consecutive manner. We will write a complete code in JavaScript with different approaches and examples to understand the process better. Introduction to Problem In the given problem, we are given a linked list and we have to print all of its elements in reverse order, but we don't have to reverse the given linked list. For example − Given linked list: 1 2 3 4 5 6 Result: 6 5 4 3 2 1 We will use two methods ...
Read MoreHow to stop event propagation with inline onclick attribute in JavaScript?
Event propagation in JavaScript causes events to bubble up from child elements to their parents. When you have nested elements with click handlers, clicking a child element triggers both the child and parent handlers. The stopPropagation() method prevents this bubbling behavior. Understanding Event Propagation Let's see how event propagation works with nested elements: .parent-div { width: 300px; height: 150px; ...
Read MoreJavaScript Program for Products of ranges in an array
We will be given an array and we have to answer some queries related to the given range that is from a given starting index to the ending point or index we have to return the product of the elements in that range. We will see some approaches in this article to implement the above problem in JavaScript with the explanation. Introduction to Problem We are given an array and some queries, in each query we will be given some ranges by indicating the first and the last index of the range and we have to answer the ...
Read MoreHow to change font style using drop-down list in JavaScript?
In JavaScript, you can change the font style of text elements using a dropdown list by combining HTML select elements with the style.fontFamily property. This creates an interactive way for users to change text appearance dynamically. A dropdown list (select element) allows users to choose from multiple font options. When a selection is made, JavaScript captures the change event and applies the selected font to target elements. Syntax The basic syntax for changing font family using JavaScript: element.style.fontFamily = "fontName"; HTML select element with options: Arial ...
Read MoreJavaScript Program to Cyclically Rotate an Array by One
To cyclically rotate an array by one means shifting the value present at each index to their left or right by one. In this article, we are having an array and our task is to write a JavaScript program to cyclically rotate an array by one. Users must be familiar with JavaScript loops and array operations. Original Array: 1 2 3 ...
Read MoreHow to terminate a script in JavaScript?
The termination of the script means that it stops executing the JavaScript code. In some emergency cases, developers require to abort the execution of JavaScript code in the middle while the script is executing. Also, we can use the if-else statement to decide when to terminate the script execution and when to continue. Here, we will learn different ways to terminate the script midway. Use the Return Statement The return statement is used to terminate the execution of any code inside the function. Once we execute the return statement inside the function, the code written after the ...
Read MoreJavaScript Program for Queries to find the maximum sum of contiguous subarrays of a given length in a rotating array
Rotating array means we will be given a number and we have to move the elements of the array in cyclic order in either the right or left direction. Here we are not specified so we will use the right rotation as the standard and after the given number of rotations, we will return the subarrays with the maximum sum. We will see the code with the proper explanation in the article. Introduction to Problem In this problem, we are given an array that contains the integers and another array that contains the pairs of queries. Each index ...
Read MoreHow to test a value x against predicate function and returns fn(x) or x in JavaScript?
Testing a value x against a predicate function means checking if x meets a specific condition. If the condition is true, we apply a transformation function to x and return the result. Otherwise, we return the original value x unchanged. Syntax The basic syntax uses the ternary operator to test a value against a predicate function: let result = predicate(x) ? operation(x) : x; Where predicate(x) returns true/false, and operation(x) transforms the value when the predicate passes. Basic Example Here's a simple example that squares numbers greater than 5, otherwise returns the ...
Read MoreHow to change the font-weight of a text using JavaScript?
Using JavaScript is one of the most effective ways to dynamically change the font-weight of any text on your webpage. Font weight refers to the boldness or thinness of characters, ranging from 100 (thin) to 900 (black/heavy). In this article, we will explore how to change font-weight using JavaScript for both single and multiple elements. Using the Style fontWeight Property The style.fontWeight property allows us to change the font weight of individual HTML elements. This property accepts both numeric values and keyword values. Syntax document.getElementById("elementId").style.fontWeight = "normal|lighter|bold|bolder|100-900|initial|inherit"; You can assign numeric values (100-900) ...
Read MoreJavaScript Program for Quicksort On Singly Linked List
The singly-linked list is a linear data structure that consists of nodes. Each node contains data and a pointer to the next node, which holds the memory address of the next node since memory allocation for nodes is not continuous. Sorting arranges elements of a data structure like linked lists or arrays in a specific order, typically ascending. In this article, we'll implement the quicksort algorithm on a singly linked list using JavaScript. Introduction to Problem QuickSort is a divide-and-conquer sorting algorithm that uses recursion. It has an average time complexity of O(N * log(N)), making it ...
Read More