Articles on Trending Technologies

Technical articles with clear explanations and examples

In JavaScript, need to perform sum of dynamic array

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 393 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 616 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 191 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 306 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

JavaScript function to accept a string and mirrors its alphabet

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 376 Views

We need to write a function that accepts a string and mirrors its alphabet. This means each letter is replaced with its counterpart from the opposite end of the alphabet. If the input is 'abcd' The output should be 'zyxw' The function maps every character to the letter that is (26 - N) positions away from it, where N is the 1-based index of that alphabet (like 5 for 'e' and 10 for 'j'). How It Works We use the String.prototype.replace() method to match all English alphabets regardless of case. For each letter: ...

Read More

Remove elements from array in JavaScript using includes() and splice()?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 416 Views

The includes() method checks whether an array contains a specific element, while splice() is used to add or remove items from an array. Together, they can be used to remove multiple elements from an array efficiently. Syntax array.includes(searchElement) array.splice(start, deleteCount) How It Works The approach involves iterating through the array and using includes() to check if each element should be removed. When a match is found, splice() removes it, and the index is decremented to account for the array shift. Example deleteElementsFromArray = function(elements, ...values) { let elementRemoved ...

Read More
Showing 18371–18380 of 61,297 articles
Advertisements