Articles on Trending Technologies

Technical articles with clear explanations and examples

Play infinitely looping video on-load in HTML5

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

HTML5 provides built-in support for playing videos that loop infinitely using the loop attribute. This is useful for background videos, animations, or promotional content that should continuously play. Basic Syntax The element supports three main video formats: MP4, WebM, and Ogg. To create an infinitely looping video, combine the autoplay and loop attributes: Your browser does not support the video element. Key Attributes autoplay: Starts the video automatically when the page loads loop: A boolean attribute that restarts ...

Read More

Dijkstra's algorithm in Javascript

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

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a weighted graph. We'll use the new addEdge and addDirectedEdge methods to add weights to the edges when creating a graph. Let us look at how this algorithm works − Create a distance collection and set all vertices distances as infinity except the source node. Enqueue the source node in a min-priority queue with priority 0 as the distance is 0. Start a loop till the priority queue is empty and dequeue the ...

Read More

How to toggle between a like/dislike button with CSS and JavaScript?

Vivek Verma
Vivek Verma
Updated on 15-Mar-2026 2K+ Views

Creating a toggle between like and dislike buttons is a common interactive feature on websites. This article demonstrates how to implement this functionality using HTML, CSS, and JavaScript with Font Awesome icons. HTML Structure The HTML file creates the basic structure with a button containing a thumbs-up icon and display elements for both like and dislike states. Toggle Toggle between a like/dislike button with CSS and JavaScript? ...

Read More

Default exports vs Named exports in JavaScript

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

In this article, we will learn the difference between default exports and named exports in JavaScript, and how we can use them to effectively organize our code structure. In JavaScript, we can use default exports and named exports to have separate files or modules for separate pieces of code. This helps in enhancing code readability and tree shaking to a great extent. Default exports Named exports A ...

Read More

What is the simplest solution to flat a JavaScript array of objects into an object?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 200 Views

Flattening an array of objects into a single object combines all key-value pairs from the array elements. The simplest solution uses the reduce() method with the spread operator. Problem Example Consider an array of objects where each object contains different properties: const studentDetails = [ {Name: "Chris"}, {Age: 22} ]; console.log("Original array:", studentDetails); Original array: [ { Name: 'Chris' }, { Age: 22 } ] Using reduce() with Spread Operator The reduce() method iterates through the array and combines all objects into ...

Read More

How to insert an element into all positions in an array using recursion - JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 561 Views

We are required to declare a function, let's say insertAllPositions, which takes two arguments — an element, x, and an array, arr. Functions must return an array of arrays, with each array corresponding to arr with x inserted in a possible position. That is, if arr is the length N, then the result is an array with N + 1 arrays — For example, the result of insertAllPositions(10, [1, 2, 3]) should be — const output = [ [10, 1, 2, 3], [1, 10, 2, 3], ...

Read More

How to set the shape of the border of the top-right corner with JavaScript?

Fendadis John
Fendadis John
Updated on 15-Mar-2026 267 Views

To set the shape of the border of the top-right corner in JavaScript, use the borderTopRightRadius property. This property allows you to create rounded corners by specifying the radius value. Syntax element.style.borderTopRightRadius = "value"; The value can be specified in pixels (px), percentages (%), or other CSS units like em or rem. Example Here's how to dynamically change the top-right border radius using JavaScript: #box { ...

Read More

How to toggle between hiding and showing an element with JavaScript?

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

To toggle between hiding and showing an element with JavaScript, you can manipulate the element's display CSS property. This technique is commonly used for creating interactive user interfaces where content needs to be dynamically shown or hidden. Basic Toggle Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } button { ...

Read More

Equivalent of Ruby's each cons in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 400 Views

Ruby's each_cons() method iterates through consecutive N elements of an enumerable, creating subarrays of fixed size. JavaScript doesn't have this built-in, but we can implement it using Array prototype extension. Understanding each_cons Behavior The each_cons(n) function creates sliding windows of size n from an array. For each starting position, it takes n consecutive elements until there aren't enough remaining elements. const arr = [1, 2, 3, 4, 5]; // With n=2: creates pairs starting from each position // Result: [[1, 2], [2, 3], [3, 4], [4, 5]] // With n=3: creates triplets starting from ...

Read More

Filter array with filter() and includes() in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 15-Mar-2026 14K+ Views

In this article, using the filter() and includes() methods in JavaScript, we can filter an array based on the elements presence in another array or specific conditions. For example, if we have two arrays as array1 and array2, we want to filter array1 to include only the elements that are present in array2. To have a clear idea about the filter() and includes() methods in JavaScript, let's discuss them individually. JavaScript filter() and includes() Methods filter(): Creates a new array that includes only the elements that satisfy the condition provided by the callback function. includes(): ...

Read More
Showing 11791–11800 of 61,304 articles
Advertisements