Javascript Articles

Page 7 of 534

How to sort an array on multiple columns using JavaScript?

Abhishek
Abhishek
Updated on 15-Mar-2026 549 Views

An array with multiple columns is an array that contains multiple elements at each index position. In other words, it's an array of arrays where each sub-array represents a row with multiple column values that need to be sorted based on specific criteria. In this article, we'll learn how to sort arrays with multiple columns using JavaScript's sort() method combined with custom comparator functions. We'll explore different sorting strategies for various data types. Basic Syntax The fundamental approach uses a custom comparator function with the sort() method: array.sort((a, b) => { ...

Read More

Top 8 JavaScript Books For Beginners to Advanced

vivek Raj Singh
vivek Raj Singh
Updated on 15-Mar-2026 577 Views

JavaScript is a versatile, powerful language that can also be used for server-side scripting, opening up numerous career opportunities in web development. Understanding JavaScript is essential whether you're just starting out or already on your coding journey. The recommended books below offer various approaches to mastering JavaScript, helping you become a more creative and effective developer. Top 8 JavaScript Books For Beginners to Advanced Here are my top 8 book recommendations for mastering JavaScript. Whether you're a beginner or an experienced developer, there's something valuable for everyone on this list. JavaScript: The ...

Read More

How To Password Protect A Page Using Only HTML, CSS And JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 27K+ Views

To password protect a page using only HTML, CSS and JavaScript, is an important security measure for webpages that contain sensitive information or require authentication for access. In this article, we will understand how to create a simple form that requires users to enter a password before they can view the content of your protected page. Note: Client-side password protection provides basic content hiding but is not secure for truly sensitive data. For real security, use server-side authentication. Approaches to Password Protect a Page Here are two approaches to password protect a page using only HTML, CSS ...

Read More

Accessing metadata from an audio files using JavaScript

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 3K+ Views

Audio files contain embedded metadata such as title, artist, album, genre, and year. This metadata is valuable for media players, music libraries, and cataloging applications. JavaScript provides several approaches to access this information, ranging from basic HTML5 audio properties to dedicated libraries for extracting ID3 tags. Approaches to Access Audio Metadata Using the HTML5 Audio Element Using Web Audio API Using ID3 Libraries (jsmediatags) Using the HTML5 Audio Element The HTML5 audio element provides basic metadata access like duration and playback information. However, it ...

Read More

How to Select a Random Element from Array in JavaScript?

Rohan Singh
Rohan Singh
Updated on 15-Mar-2026 4K+ Views

To select a random element from array in JavaScript, means getting any random element from the given array. We will understand various approaches for selecting a random element from array. In this article, we are having an array and our task is to select a random element from array in JavaScript Approaches to Select a Random Element from Array Here are the most effective approaches to select a random element from array in JavaScript which we will be discussing in this article with stepwise explanation and complete example codes. Using Math.random() ...

Read More

How to Trigger a File Download when Clicking an HTML Button or JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 49K+ Views

To trigger a file download when clicking an HTML button or JavaScript, is a very common and important part of web page where users can directly download the file they want by clicking a button or link. We will be understanding four different approaches to achieve this. In this article, we are having a button in our HTML document and our task is to trigger a file download when clicking an HTML button or JavaScript. Approaches to trigger file download Here is a list of approaches to trigger a file download when clicking an HTML button or ...

Read More

JavaScript program to find if there is a subarray with 0 sum

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 660 Views

A subarray with a sum of 0 is a sequence of contiguous elements within an array where the sum of all elements in that sequence equals zero. Identifying such subarrays is a common problem in data analysis and coding challenges. The prefix sum technique efficiently solves this problem. In this article we will find if there is a subarray with 0 sum using JavaScript. The key insight is to use prefix sums (cumulative sums) along with a data structure to track previously seen sums: Continuously calculate the prefix sum while traversing the array ...

Read More

JavaScript Program to Find k Pairs with Smallest Sums in Two Arrays

Saurabh Anand
Saurabh Anand
Updated on 15-Mar-2026 430 Views

To find k pairs with smallest sums in two arrays in JavaScript, we will be using sorted arrays in ascending order. We are going to discuss two different approaches with stepwise explanation and examples. In this article we are having two arrays and a value of k, our task is to find k pairs with smallest sums in two arrays. Users must be familiar with JavaScript arrays, loops and conditional statement. Example Input: arr1 = [1, 7, 11], arr2 = [2, 4, 6] k = 3 Output: [[1, 2], [1, 4], [1, 6]] Input: ...

Read More

JavaScript Program to Find Closest Number in Array

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

To find closest number in array using JavaScript, we will be understanding and discussing three different approaches. We will also compare time and space complexities of all the approaches used. In this article we are having an array and a target value, our task is to find closest number to target value in array using JavaScript. User must know about JavaScript arrays, searching algorithms such as linear and binary search, sorting, loops, and conditional statements. Approaches to Find Closest Number in Array Here is a list of approaches to find closest number in array in JavaScript which ...

Read More

JavaScript Robotics: Controlling Hardware with Johnny-Five and Arduino

Mukul Latiyan
Mukul Latiyan
Updated on 15-Mar-2026 604 Views

JavaScript is no longer limited to web development; it has expanded into controlling hardware devices, thanks to frameworks like Johnny-Five. Johnny-Five is a powerful and user-friendly JavaScript robotics library that allows developers to interact with hardware components like LEDs, motors, sensors, and more using microcontrollers such as Arduino. What is Johnny-Five? Johnny-Five is a JavaScript robotics and IoT (Internet of Things) platform that allows you to control hardware devices using JavaScript. It provides a simple and intuitive API that abstracts the complexities of working with electronics, making it easier for developers to prototype and experiment with physical computing ...

Read More
Showing 61–70 of 5,340 articles
« Prev 1 5 6 7 8 9 534 Next »
Advertisements