Articles on Trending Technologies

Technical articles with clear explanations and examples

Kruskal's algorithm in Javascript

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

Kruskal's algorithm is a greedy algorithm used to find the minimum spanning tree (MST) of a weighted, undirected graph. It works by systematically selecting the smallest weight edges while avoiding cycles. How Kruskal's Algorithm Works The algorithm follows these steps: Create a set of all edges in the graph Sort all edges by weight in ascending order While the set is not empty and not all vertices are covered: Remove the minimum weight edge from the set Check if this edge forms a cycle. If not, ...

Read More

How to toggle between adding and removing a class name from an element with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 277 Views

JavaScript provides several methods to toggle class names on HTML elements. The most efficient approach is using the classList.toggle() method, which automatically adds a class if it doesn't exist or removes it if it does. Using classList.toggle() Method The toggle() method is the simplest way to switch between adding and removing a class: .highlight { background-color: #3498db; ...

Read More

In JavaScript, need to perform sum of dynamic array

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 386 Views

Let's say, we have an array that contains the score of some players in different sports. The scores are represented like this − const scores = [ {sport: 'cricket', aman: 54, vishal: 65, jay: 43, hardik: 88, karan:23}, {sport: 'soccer', aman: 14, vishal: 75, jay: 41, hardik: 13, karan:73}, {sport: 'hockey', aman: 43, vishal: 35, jay: 53, hardik: 43, karan:29}, {sport: 'volleyball', aman: 76, vishal: 22, jay: 36, hardik: 24, karan:47}, {sport: 'baseball', aman: 87, vishal: 57, jay: 48, hardik: 69, karan:37}, ]; We need to ...

Read More

How to print all students name having percentage more than 70% in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 609 Views

You can filter and display students with percentage more than 70% using various JavaScript approaches. This is useful for grade-based filtering and reporting. Following are the records of each student: const studentDetails = [ { studentName: "John", percentage: 78 }, { studentName: "Sam", percentage: 68 }, ...

Read More

How to access variables declared in a function, from another function using JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

In JavaScript, variables declared inside a function are scoped to that function and cannot be directly accessed from outside. However, there are several ways to make these variables available to other functions or globally. Problem with Function Scope Variables declared inside a function are private to that function: function myFunction() { let localVar = "I'm inside the function"; } myFunction(); // console.log(localVar); // This would cause an error Using Constructor Functions with 'this' You can use constructor functions to expose internal variables as properties: const num ...

Read More

Regular expression to match numbers only in JavaScript?

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

In this tutorial, we will learn regular expressions to match numbers only in JavaScript. Data validation is essential for web applications. We often need to ensure users provide correct input — for example, phone numbers should contain only digits, or credit card fields should accept numbers only. Regular expressions provide a powerful way to validate and extract numeric data from strings. They use patterns to match specific character types and return the matched results. Understanding Regular Expression Patterns A regular expression consists of a pattern and optional modifiers. For matching numbers, we use: \d ...

Read More

What is the difference between setTimeout() and setInterval() in JavaScript?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 2K+ Views

JavaScript provides two timing functions: setTimeout() for one-time execution and setInterval() for repeated execution at specified intervals. setTimeout() Function setTimeout(function, delay) executes a function once after a specified delay in milliseconds. Syntax setTimeout(function, delay); setTimeout(callback, delay, param1, param2, ...); Example setTimeout(function() { console.log('This runs once after 2 seconds'); }, 2000); console.log('This runs immediately'); This runs immediately This runs once after 2 seconds setInterval() Function setInterval(function, delay) executes a function repeatedly at specified intervals until ...

Read More

What will happen when { } is converted to String in JavaScript?

Arushi
Arushi
Updated on 15-Mar-2026 182 Views

In JavaScript, when an empty object {} is converted to a string, it becomes "[object Object]". This happens because JavaScript calls the object's toString() method during string conversion. How Object to String Conversion Works JavaScript follows these steps when converting an object to a string: First, it calls the object's toString() method For plain objects, toString() returns "[object Object]" This is the default string representation for all plain objects Example: Converting Empty Object to String Convert {} to String ...

Read More

ffmpeg settings for converting to mp4 and ogg for HTML5 video

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

Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg. HTML5 video requires specific codecs for cross-browser compatibility. MP4 with H.264/AAC works in most browsers, while OGV with Theora/Vorbis supports Firefox and other open-source browsers. Converting to MP4 Format When converting to MP4, use the H.264 video codec and AAC audio codec for maximum browser compatibility, especially IE11 and earlier versions. ffmpeg -i input.mov -vcodec h264 -acodec aac -strict -2 output.mp4 This command converts input.mov to output.mp4 with H.264 video and AAC audio codecs. MP4 with Maximum Compatibility ...

Read More

Complete Graph Class in Javascript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 296 Views

This article presents a comprehensive Graph class implementation in JavaScript with various graph algorithms including traversal, shortest path, and minimum spanning tree algorithms. Graph Class Structure The Graph class uses an adjacency list representation with two main properties: nodes - Array storing all graph vertices edges - Object mapping each node to its connected neighbors with weights Basic Graph Operations const Queue = require("./Queue"); const Stack = require("./Stack"); const PriorityQueue = require("./PriorityQueue"); class Graph { constructor() { this.edges = {}; ...

Read More
Showing 11821–11830 of 61,304 articles
Advertisements