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
Working with forms in React.js
In simple HTML forms, form elements maintain their values internally and submit when the form submission button is clicked. React provides a more controlled approach to handling forms through controlled components. HTML Form Example Form Example User Name: ...
Read MoreProgram to check/uncheck checkboxes using JavaScript
We will learn how to check or uncheck checkboxes in JavaScript in this article, and how we can use it to allow users to make multiple selections on web pages. Checkboxes are one of the most used HTML elements in forms and user interfaces that allow users to pick multiple options. In JavaScript, we can dynamically check or uncheck checkboxes based on certain conditions or user interactions. Let's look at some examples to understand the concept better: Basic Check All/Uncheck All In this example, we will: Create 3 different checkboxes with ...
Read MoreFind distinct elements - JavaScript
We are required to write a JavaScript function that takes in an array of literals, such that some array elements are repeated. We are required to return an array that contains elements that appear only once (not repeated). For example: If the array is: const arr = [9, 5, 6, 8, 7, 7, 1, 1, 1, 1, 1, 9, 8]; Then the output should be: const output = [5, 6]; Using indexOf() and lastIndexOf() The first approach uses indexOf() and lastIndexOf() to check if an element appears only once. If ...
Read MoreChecking whether the sum of digits of a number forms a Palindrome Number or not in JavaScript
We are required to write a JavaScript function that takes in a number, sums its digits and checks whether that sum is a Palindrome number or not. The function should return true if the sum is Palindrome, false otherwise. For example, if the number is 697, then the sum of its digits will be 6 + 9 + 7 = 22, which indeed, is a Palindrome number. Therefore, our function should return true for 697. Understanding the Problem A palindrome number reads the same forwards and backwards. For example: 11, 22, 121, 1331 are palindromes. Our task ...
Read MoreHow to convert epoch Date to meaningful JavaScript date?
In this tutorial, we will learn to convert the epoch Date to a meaningful JavaScript date. The epoch date is a representation of the date in milliseconds, and it is a total number of milliseconds since 1st January 1970 since the UNIX epochs started. Users can convert the total number of milliseconds into the meaningful date string using various approaches explained below. Using the new Date() Object In this approach, we will create the object of the Date class. The constructor of the Date() class takes the total number of milliseconds since the epoch started and converts ...
Read MoreWhat should be done with the left/ right edges of the content on overflow with JavaScript?
When content overflows horizontally in a container, the overflowX property controls how the left and right edges are handled. This property allows you to add horizontal scrolling, hide overflow, or make it visible. Syntax element.style.overflowX = "value"; Common overflowX Values Value Description Use Case scroll Always shows horizontal scrollbar ...
Read MoreWebGL: Prevent color buffer from being cleared in HTML5
In WebGL, the color buffer is automatically cleared at the beginning of each frame by default. This can be problematic when you want to preserve previous drawings for effects like trails or persistent graphics. The Problem Even when you manually clear the color buffer using clearColor() and clear(), the WebGL context automatically clears the drawing buffer before the next frame: // Manual clearing - but buffer still gets cleared automatically gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clear(gl.COLOR_BUFFER_BIT); This automatic clearing happens at the beginning of the next draw cycle, making it impossible to build up graphics ...
Read MoreIn-order traversal in Javascript Tree
The tree is a data structure that is comprised of nodes and edges. These entities are interconnected to each other to form a tree structure. Traversing a data structure means visiting each and every node in that structure and bringing out a sequence of values from that. There are three types of traversals namely, in-order (L→ Root→R ), pre-order(Root→L→R) and, post-order(L→ R → Root) In-order Traversal In the In-order Traversal, the left subtree is visited first, followed by the Root node and finally the right subtree. A binary tree will provide sorted key values in ascending order ...
Read MoreHow to add delay in a loop in JavaScript?
Loops are used in JavaScript to repeat actions or iterate over data. Adding delays between iterations helps control execution speed, create animations, or prevent overwhelming the browser. This article demonstrates how to add delays in JavaScript loops using different techniques. Let's explore practical examples to understand the concept better. Using setTimeout() with Recursive Functions The setTimeout() approach uses recursion to process each array element with a delay: function delayedLoop() { var items = [1, 2, 3, 4, 5]; var delay = 1000; // 1 second ...
Read MoreHow do I run two or more functions when using 'onclick' JavaScript?
When handling click events in JavaScript, you often need to execute multiple functions. There are several ways to run two or more functions when using the onclick event. Method 1: Using a Wrapper Function Create a single function that calls multiple functions inside it: Multiple Functions onClick Call Functions function callTwoFunctions() { ...
Read More