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
How -Infinity is converted to String in JavaScript?
In JavaScript, -Infinity is a special numeric value that represents negative infinity. When we need to convert it to a string, we can use the String() method or the toString() method. The -Infinity value typically results from mathematical operations like dividing a negative number by zero or when a calculation exceeds the minimum representable number in JavaScript. Syntax The String() method converts any JavaScript value to a string representation: String(value) Where value is any JavaScript value. The method returns the string representation of that value. Using String() Method The most reliable ...
Read MoreStop Web Workers in HTML5
Web Workers allow for long-running scripts that are not interrupted by scripts that respond to clicks or other user interactions and allows long tasks to be executed without yielding to keep the page responsive. Web Workers don't stop by themselves but the page that started them can stop them by calling the terminate() method. Syntax worker.terminate(); Example: Creating and Terminating a Web Worker First, let's create a simple Web Worker script (worker.js): // worker.js self.onmessage = function(e) { let count = 0; while ...
Read MoreAVL Tree class in Javascript
An AVL Tree is a self-balancing binary search tree where the heights of left and right subtrees differ by at most one. This implementation provides insertion with automatic rebalancing through rotations. 10 5 15 3 7 Balanced AVL Tree (height difference ...
Read MoreHow to remove event handlers in JavaScript?
An event is defined as a change in an object's state. There are a number of events in HTML that show when a user or browser performs a certain action. JavaScript responds to these events when JavaScript code is embedded in HTML and allows execution. The process of responding to events is known as event handling. As a result, JavaScript uses event handlers to handle HTML events. In this article, we are going to discuss how to remove event handlers in JavaScript. Here, we use the removeEventListener() method to remove an event handler from an element in JavaScript. ...
Read MoreHow to draw on scroll using JavaScript and SVG?
Drawing on scroll using JavaScript and SVG creates an engaging animation effect where an SVG path gradually appears as the user scrolls down the page. This technique uses stroke-dasharray and stroke-dashoffset properties to control path visibility. How It Works The technique uses SVG's stroke-dasharray and stroke-dashoffset properties to hide the path initially, then gradually reveals it based on scroll position. The path length is calculated and used to synchronize the drawing with scroll progress. SVG Path Drawing Animation Initial State (Hidden) ...
Read MoreExports & Imports in JavaScript
JavaScript exports and imports enable modular development by allowing us to organize code into reusable modules. This feature helps break down large applications into smaller, maintainable pieces that can be shared across different parts of your codebase. Exports make functions, variables, objects, or any values available outside of a module, while imports bring exported components from other modules into the current module. JavaScript supports two main types of exports: named exports and default exports. Named Exports and Imports Named exports allow you to export multiple components from a single module. Each export must be explicitly named when ...
Read MoreDetermining full house in poker - JavaScript
A "full house" in poker is a hand containing three cards of one rank and two cards of another rank (e.g., three Kings and two Aces). We need to write a JavaScript function that checks if an array of five cards represents a full house. Understanding Full House A full house requires exactly: Three cards of the same rank (three of a kind) Two cards of another same rank (a pair) Example Implementation Here's a JavaScript function to detect a full house: const arr1 = ['K', 'K', 'K', 'A', 'A']; // Full ...
Read MoreHow to get the numbers which can divide all values in an array - JavaScript
We are required to write a JavaScript function that takes in an array of numbers and returns a number which can exactly divide all the numbers in the array. Let's say the following is our array: const arr = [4, 6, 34, 76, 78, 44, 34, 26, 88, 76, 42]; Understanding the Problem We need to find the common divisors that can divide all numbers in the array. This is essentially finding the Greatest Common Divisor (GCD) of all array elements and then finding all its divisors. Method 1: Finding All Common Divisors ...
Read MoreHow do I subtract minutes from a date in JavaScript?
In this tutorial, we will learn to subtract minutes from a date in JavaScript. Working with dates is a common requirement in web development, and JavaScript provides built-in Date class methods to handle date manipulations effectively. We'll explore three approaches: using native JavaScript methods getMinutes() and setMinutes(), working with milliseconds, and using the Moment.js library for more convenient date operations. Using the getMinutes() and setMinutes() Methods This approach uses the Date object's built-in methods to extract current minutes, subtract the desired amount, and update the date object. Syntax let date = new Date(set_date); let ...
Read MoreHow to list down all the plug-in installed in your browser?
To list down all the plug-ins installed in the web browser, use the JavaScript navigator object. The JavaScript navigator object includes a child object called plugins. This object is an array, with one entry for each plug-in installed on the browser. Understanding navigator.plugins The navigator.plugins property returns a PluginArray object containing Plugin objects representing the plugins installed in the browser. Each plugin object has properties like name, filename, and description. Example You can try to run the following code to list down all the plug-ins installed in your browser: ...
Read More