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
Searching for minimum and maximum values in an Javascript Binary Search Tree
In this article, we will explain how to find the minimum and maximum values in a binary search tree (BST), with implementation in JavaScript. A binary search tree is a data structure that stores data in a sorted order such that for every node, the left subtree contains values less than the node's value, and the right subtree contains values greater than the node's value. So the leftmost node will have the minimum value, and the rightmost node will have the maximum value. Find Minimum and Maximum in a BST Given root node of a binary search ...
Read MoreHow to create a speed converter with HTML and JavaScript?
To create a speed converter with HTML and JavaScript, we'll build a simple web application that converts kilometers per hour to meters per second. This involves HTML for the interface and JavaScript for the conversion logic. HTML Structure The HTML creates the user interface with an input field for entering speed values and a display area for the converted result: body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; padding: 20px; ...
Read MoreWhat does fluent wait perform?
Fluent wait is a dynamic wait mechanism in Selenium that allows the WebDriver to pause and repeatedly check for a condition at regular intervals before throwing an exception. Unlike implicit wait, FluentWait provides more control over polling frequency and exception handling. How FluentWait Works FluentWait monitors the DOM at regular intervals (defined by polling frequency) rather than constantly checking. For example, if you set a 30-second timeout with 3-second polling, the driver will check the condition every 3 seconds for up to 30 seconds before timing out. Syntax Wait wait = new FluentWait(driver) ...
Read MoreBetter ways to modify string with multiple methods using JavaScript
JavaScript provides several string methods that can be combined to modify and format strings effectively. You can use methods like toLowerCase(), toUpperCase(), charAt(), and slice() together to achieve proper string formatting. Let's say we have the following mixed-case string: var sentence = "tHIS iS tHE JavaScript pROGRAM"; console.log("Original:", sentence); Original: tHIS iS tHE JavaScript pROGRAM Method 1: Using charAt() and slice() This approach capitalizes the first letter and converts the rest to lowercase: var sentence = "tHIS iS tHE JavaScript pROGRAM"; function modifyStringWithMultipleMethods(sentence) { ...
Read MoreSwap certain element from end and start of array - JavaScript
We need to write a JavaScript function that accepts an array of numbers and a position k, then swaps the kth element from the beginning with the kth element from the end of the array. Understanding the Problem For an array with indices 0 to n-1, the kth element from start is at index k-1, and the kth element from end is at index n-k. We swap these two elements. Example Implementation const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; const swapNth = (arr, k) => { ...
Read MoreHow do you Convert a String to a Character Array in JavaScript?
Converting a string to a character array in JavaScript is useful when you want to iterate over each character or manipulate individual characters. JavaScript provides several built-in methods and techniques to accomplish this transformation. In this article, we'll explore five different approaches to convert a string to a character array in JavaScript, each with its own advantages and use cases. Approaches to Convert String to Character Array Here are the five methods we'll cover with complete examples and explanations: Using split() Method Using Array.from() Method ...
Read MoreHow to get the largest of zero or more numbers in JavaScript?
In this tutorial, we will look at how to get the largest of zero or more numbers in JavaScript. The maximum of multiple numbers can be found using different techniques. The first technique we will introduce is the Math.max() method. The second technique will be the for-loop method. Following are the methods to get the largest of zero or more numbers in JavaScript − Using the Math.max() Method We can use the Math.max() method to find the largest of many numbers. It returns the largest value from the given multiple values. The input parameters should be ...
Read MoreHow to use an HTML button to call a JavaScript function?
We use the onclick event attribute property of the HTML button to call a JavaScript function. The JavaScript code provided in the onclick attribute executes when the button is clicked. There are various attributes provided with the button tag in HTML that allows us to customize the button's functionality and also let us decide how and what the button triggers. Using the onclick Event in JavaScript The onclick event of the button element expects JavaScript code that is triggered when the button is clicked upon. So we put the function that needs to be called in the onclick ...
Read MoreHow is NaN converted to Boolean in JavaScript?
In JavaScript, NaN (Not a Number) is a special numeric value that represents an invalid number. When converted to Boolean, NaN is always considered a falsy value. This article explores three methods to convert NaN to Boolean. Using the Boolean() Function Using the !! Operator Using the NOT Operator and isNaN() Method Understanding NaN as a Falsy Value In JavaScript, NaN is one of the falsy values (along with false, 0, "", null, and undefined). This means it always converts to false in Boolean contexts. Using the Boolean() Function The Boolean() function converts ...
Read MoreHTML5 using src using raw binary data
HTML5 allows you to embed binary data directly into src attributes using Data URLs. This is particularly useful when working with files stored in databases or when you need to display content without making separate HTTP requests. Data URL Syntax Data URLs follow this format: data:[mediatype][;base64], data Where: mediatype: MIME type (image/png, audio/mp3, etc.) base64: Optional encoding specification data: The actual binary data (base64 encoded if specified) Using Binary Data with Images For images, you can embed binary data directly in ...
Read More