Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Web Development Articles
Page 121 of 801
How to sort an array on multiple columns using JavaScript?
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 MoreHow To Password Protect A Page Using Only HTML, CSS And JavaScript?
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 MoreAccessing metadata from an audio files using JavaScript
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 MoreHow to Trigger a File Download when Clicking an HTML Button or JavaScript?
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 MoreJavaScript program to find if there is a subarray with 0 sum
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 MoreJavaScript Program to Find k Pairs with Smallest Sums in Two Arrays
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 MoreJavaScript Program to Find Closest Number in Array
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 MoreJavaScript Robotics: Controlling Hardware with Johnny-Five and Arduino
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 MoreJavaScript Program to Check if a Matrix is Symmetric
A symmetric matrix is a square matrix that equals its transpose, meaning element at position (i, j) equals element at position (j, i). In mathematical terms, A = AT, where A is the matrix and AT is its transpose. In this article, we'll explore JavaScript programs to check if a given matrix is symmetric using different approaches. Original Matrix A 1 ...
Read MoreJavaScript Program to Find Difference Between Sums of Two Diagonals
To find difference between sums of two diagonals, we will be discussing two different approaches. We will calculate the sum of the elements present in the left and right diagonal, then we will subtract both sum values to get the difference. In this article we are having a square matrix, our task is to write a JavaScript program to find difference between sums of two diagonals. ...
Read More