Articles on Trending Technologies

Technical articles with clear explanations and examples

What is the role of shiftKey Mouse Event in JavaScript?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 287 Views

The shiftKey property is a boolean property of mouse events that indicates whether the Shift key was pressed when the mouse event occurred. This property is commonly used to modify the behavior of mouse interactions based on keyboard modifiers. Syntax event.shiftKey Return Value The shiftKey property returns: true - if the Shift key was pressed during the mouse event false - if the Shift key was not pressed during the mouse event Example: Basic shiftKey Detection Here's how to detect if the Shift key ...

Read More

How to find the size of localStorage in HTML?

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 741 Views

localStorage is used to persist information across multiple sessions. It has a maximum size of 5MB in most browsers and stores data as key-value pairs. Understanding localStorage Size Calculation Each character in localStorage is stored as UTF-16, taking 2 bytes. To calculate the size, we multiply the string length by 2 and convert to MB. Example: Calculate localStorage Size You can try to run the following code snippet to check the size allocated: localStorage Size Calculator localStorage Size Breakdown ...

Read More

Graph Traversals in Javascript

Sai Subramanyam
Sai Subramanyam
Updated on 15-Mar-2026 286 Views

Graph traversal (also known as graph search) refers to the process of visiting (checking and/or updating) each vertex in a graph. Such traversals are classified by the order in which the vertices are visited. In JavaScript, the two most common graph traversal algorithms are Breadth-First Search (BFS) and Depth-First Search (DFS). Both algorithms systematically explore graph nodes but use different strategies. Graph Representation First, let's create a simple graph using an adjacency list representation: class Graph { constructor() { this.adjacencyList = {}; ...

Read More

Dynamic Programming in JavaScript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 3K+ Views

Dynamic programming breaks down complex problems into smaller sub-problems and stores their solutions to avoid redundant calculations. This technique is particularly useful for optimization problems where overlapping sub-problems exist. Dynamic programming is used where we have problems that can be divided into similar sub-problems so that their results can be re-used. Before solving a sub-problem, the algorithm checks if it has already been solved and stored. The solutions of sub-problems are combined to achieve the optimal solution. When to Use Dynamic Programming For a problem to benefit from dynamic programming: The ...

Read More

JavaScript Update specific index in a boolean matrix?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 258 Views

To update a specific index in a boolean matrix in JavaScript, you can directly access the element using array indexing and assign a new boolean value. Let's explore different approaches to create and modify boolean matrices. Creating a Boolean Matrix First, let's create a boolean matrix using the fill() method: const array = Array(4); var fillWithTrueValue = array.fill(true); const matrixWithOnlyBooleanTrue = Array(4).fill(fillWithTrueValue); console.log("Original matrix:"); console.log(matrixWithOnlyBooleanTrue); Original matrix: [ [ true, true, true, true ], [ true, true, true, true ], [ true, true, true, true ], ...

Read More

How to get time difference between two timestamps in seconds?

Arushi
Arushi
Updated on 15-Mar-2026 3K+ Views

To get the time difference between two timestamps in seconds, you can subtract one Date object from another and divide by 1000. JavaScript Date objects return milliseconds when subtracted, so dividing by 1000 converts to seconds. Basic Time Difference in Seconds The simplest approach is to subtract two Date objects and convert milliseconds to seconds: Time Difference in Seconds var date1 = new Date("Jan 1, 2018 11:10:05"); ...

Read More

How to play a multimedia file using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

In this tutorial, we will learn how to play a multimedia file using JavaScript. The multimedia file is the audio and video files. The multimedia files can be of different formats. wav and mp3 are two examples of audio file formats, whereas mp4 and mkv are examples of video file formats. In HTML, multimedia files can be shown easily using different tags. We use the video tag for showing a video, and for audio, we use the audio tag. These two tags are quite similar, and many attributes are the same in both tags. The "src" attribute defines ...

Read More

How [ ] is converted to String in JavaScript?

Swarali Sree
Swarali Sree
Updated on 15-Mar-2026 224 Views

In JavaScript, an empty array [] converts to an empty string "" when converted to a string. This happens through JavaScript's automatic type conversion or by using explicit conversion methods. Using String() Method The String() method explicitly converts any value to a string: Convert [] to String var myVal = []; document.write("String: " + String(myVal)); document.write("Type: " + typeof String(myVal)); ...

Read More

How to draw an oval in HTML5 canvas?

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 1K+ Views

Drawing an oval in HTML5 canvas can be achieved by scaling a circle. Since canvas doesn't have a built-in oval method, we use the scale() transformation to stretch a circle into an elliptical shape. How It Works The technique involves three steps: Save the current canvas state with save() Apply scaling transformation to stretch the circle Draw a circle using arc(), which appears as an oval due to scaling Restore the original state with restore() Example HTML5 Canvas Oval ...

Read More

Breadth-first search traversal in Javascript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 4K+ Views

BFS visits the neighbor vertices before visiting the child vertices, and a queue is used in the search process. Following is how a BFS works − Visit the adjacent unvisited vertex. Mark it as visited. Display it. Insert it in a queue. If no adjacent vertex is found, remove the first vertex from the queue. Repeat Rule 1 and Rule 2 until the queue is empty. How BFS Traversal Works Let us look at an illustration of how BFS Traversal works: ...

Read More
Showing 18301–18310 of 61,297 articles
Advertisements