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
Inserting a node in a Javascript AVL Tree
We can learn how to insert a node in an AVL Tree. Insertions in AVL trees follow the same process as BST, but we need to perform one extra step called balance tree during insert whenever we move down the tree. This requires calculating the balance factor and applying appropriate rotation methods based on the tree configuration. The balance factor determines which type of rotation is needed to maintain the AVL property. Understanding AVL Tree Balance An AVL tree maintains balance by ensuring that for every node, the heights of its left and right subtrees differ by ...
Read MoreWhat is the relation between 'null' and '0' in JavaScript?
In JavaScript, the relationship between null and 0 creates a seemingly contradictory behavior that confuses many developers. While null is neither greater than nor equal to 0 in equality checks, it evaluates as greater than or equal to 0 in comparison operations. Understanding null and 0 null is a primitive value representing an intentional absence of value, while 0 is a number. The confusing behavior occurs due to JavaScript's type coercion rules, which differ between equality (==) and comparison (>, =,
Read MoreReplace a child node with a new node in JavaScript?
In this article we are going to learn how to replace a child node with a new node in JavaScript with suitable examples. To replace a child node with a new node, JavaScript provides two built-in DOM methods: replaceChild() and replaceWith(). Both methods allow you to swap an existing node with a new one in the DOM tree. The methods replaceChild() and replaceWith() are supported by all modern browsers and are features of the DOM specification. replaceChild() Method The replaceChild() method is called on the parent element to replace one of its child nodes. Syntax ...
Read MoreHow to create a clickable dropdown menu with CSS and JavaScript?
To create a clickable dropdown menu with CSS and JavaScript, you can build an interactive navigation component that saves space while providing easy access to multiple options. This approach helps keep your webpage clean and organized without overwhelming users with too many visible elements. In this tutorial, we'll create a dropdown menu with a toggle button and multiple navigation links, demonstrating the complete process from HTML structure to JavaScript interactivity. Steps to Create a Clickable Dropdown Menu We will follow these three essential steps to build our dropdown menu: Structuring the ...
Read MoreHow to make a fullscreen window with JavaScript?
The Fullscreen API allows you to display HTML elements in fullscreen mode. This is commonly used for videos, images, or interactive content that benefits from maximum screen real estate. Syntax element.requestFullscreen() // Standard element.webkitRequestFullscreen() // WebKit (Safari, Chrome) element.mozRequestFullScreen() // Firefox element.msRequestFullscreen() // IE/Edge Example: Video Fullscreen body { ...
Read MoreHow do JavaScript primitive/object types passed in functions?
In JavaScript, understanding how data types are passed to functions is crucial. Primitive types are passed by value, while objects are passed by reference. This affects how modifications inside functions impact the original data. Pass by Value (Primitives) Primitive types (string, number, boolean, null, undefined, symbol, bigint) are passed by value. A copy is made, so changes inside the function don't affect the original variable. Pass by Value Example function modifyPrimitive(value) { value = value + 10; document.getElementById('output').innerHTML += ...
Read MoreIs it possible to select text boxes with JavaScript?
Yes, it's possible to select text boxes with JavaScript using the select() method. This method highlights all text within an input field, making it ready for user interaction or replacement. The select() Method The select() method programmatically selects all text content in an input field. It's commonly used to improve user experience by pre-selecting text for easy editing or copying. Basic Syntax element.select(); Example: Selecting Text on Button Click Select Text Box Example ...
Read MoreSorting Array with JavaScript reduce function - JavaScript
We are required to write a JavaScript function that takes in an array of numbers. The function should sort the array without using the Array.prototype.sort() method. We are required to use the Array.prototype.reduce() method to sort the array. Let's say the following is our array: const arr = [4, 56, 5, 3, 34, 37, 89, 57, 98]; Understanding the Approach The reduce() method can be used to build a sorted array by iterating through each element and placing it in the correct position within an accumulator array. We'll use insertion sort logic within the ...
Read MoreHow to convert a date object to string with format hh:mm:ss in JavaScript?
We will learn to convert the date object to a string with the format hh:mm:ss in JavaScript. Working with dates and times is common in web development, and formatting them according to specific requirements is an essential skill. The default date object returns a complete date string, which might contain more information than needed. Here, we will explore different approaches to extract and format just the time portion in hh:mm:ss format. Using toTimeString() Method The toTimeString() method returns the time portion of a Date object as a human-readable string. We can then extract the first 8 characters ...
Read MoreHow to differentiate between Manual and Automated Animation in JavaScript?
Generally, animation in JavaScript is done to get different effects and make the object move around the page. You can move and animate any type of HTML element using manual or automated animations in JavaScript. In this tutorial, we will learn how to differentiate between manual and automated animation in JavaScript. Manual Animation Manual animation requires user interaction to trigger movement or changes. The animation process is not automated and depends on events like button clicks or mouse actions. The following implementation demonstrates a simple manual animation using DOM object properties and JavaScript functions: ...
Read More