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
Javascript Articles
Page 9 of 534
JavaScript Program for Mirror of Matrix Across Diagonal
To write a javascript program for mirror of matrix across diagonal, we will be discussing two approaches with their code examples and explanations. In this article we have a 2D matrix. Our task is to write a JavaScript program that creates a mirror of the matrix across its diagonal. This operation is also known as matrix transpose, where rows become columns and columns become rows. ...
Read MoreJavaScript Program for Rotate a Matrix by 180 degrees
To rotate a matrix by 180 degrees, we can achieve this using various approaches. In this article, we'll explore three different methods with step-by-step explanations and complete examples. A 180-degree rotation of a matrix means that the first row becomes the last row in reverse order, the second row becomes the second-to-last row in reverse order, and so on. Essentially, we're flipping the matrix both horizontally and vertically. Example Input: matrix = [[1, 2, 3, 4], [5, 6, 7, 8], ...
Read MoreJavaScript Program for Frequencies of Even and Odd Numbers in a Matrix
To get frequencies of even and odd numbers in a matrix, we will be discussing three different approaches. We will discuss each approach with code examples and solution of the algorithm being used. In this article we are having a 2D matrix, our task is to write a JavaScript program for frequencies of even and odd numbers in a matrix. Users must be familiar with conditional statement, nested loops and javascript operators. Example Input: Matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; Even numbers: {2, 4, 6, 8} Odd numbers: {1, 3, ...
Read MoreJavaScript Program for Block Swap Algorithm for Array Rotation
To implement block swap algorithm for array rotation, we will be understanding two different approaches. Rotation of the array elements means moving the elements of the given array to either the left or right side by some number of specific positions. Block swap algorithm for array rotation means to rotate the elements of the array by a given number but not using the rotation but the swapping technique. In this article we are having an array and a variable d by which array will be rotated, our task is to write a JavaScript program for block swap algorithm for ...
Read MoreJavaScript Program to Check if Matrix is Upper Triangular
To check if matrix is upper triangular matrix, we check if all the elements below the main diagonal is 0. We are going to discuss two different approaches and compare their complexities. In this article we are having a 2D square matrix, our task is to write a JavaScript program to check if matrix is upper triangular matrix. Users must be familiar with upper triangular matrix, nested for loop, conditional statement and javascript methods. ...
Read MoreJavaScript Algorithms: Sorting, Searching, and Graph Traversal
JavaScript is a versatile programming language widely used for web development. While it is known for its ability to enhance the interactivity of web pages, JavaScript also provides powerful algorithms for sorting, searching, and graph traversal. These algorithms are essential in solving complex problems efficiently. In this article, we will explore advanced JavaScript algorithms, including sorting algorithms like quicksort and mergesort, searching algorithms like binary search, and graph traversal algorithms like breadth-first search and depth-first search. Sorting Algorithms Sorting algorithms play a crucial role in organizing data in a specific order. JavaScript offers several efficient sorting algorithms, two ...
Read MoreHow to Convert JSON to Excel in JavaScript?
Converting JSON data to Excel format is a common requirement in web applications, especially for data export and reporting functionality. Excel files are widely used for data presentation and analysis, making JSON-to-Excel conversion essential for seamless data management. This article explores different methods to convert JSON data to Excel files using JavaScript, including library-based approaches and manual techniques. Approaches to Convert JSON to Excel in JavaScript Using the SheetJS (xlsx) library Manual HTML Table Export Exporting JSON to CSV format Using the SheetJS ...
Read MoreHow to splice an array without mutating the original Array?
In JavaScript, the splice() method modifies the original array by adding, removing, or replacing elements. However, sometimes you need to perform splice operations without changing the original array. This tutorial demonstrates three effective approaches to splice arrays while preserving the original data. Understanding the splice() Method The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place. Syntax array.splice(startIndex, deleteCount, item1, item2, ..., itemN) Parameters startIndex − The index at which to start changing the array deleteCount − The number of ...
Read MoreHow to trigger the HTML button after hitting enter button in the textbox using JavaScript?
Generally, developers add the submit button to submit the input field's text. However, if they allow users to submit the input value by pressing enter, it improves the UX of the application. Here, we will learn the general way to detect the key press using the key listener event. Afterwards, we can perform any operation whenever the user presses the enter key button. Syntax Users can follow the syntax below to detect whenever the user presses the enter key. input.addEventListener("keypress", function (event) { if (event.keyCode == 13) { ...
Read MoreHow to trigger the onchange event on input type=range while dragging in Firefox?
The range input allows users to select any value within a specified range. By default, the onchange event only triggers when the user releases the mouse, not during dragging. This creates poor user experience as users can't see real-time value updates. The onchange event triggers only when the user releases the mouse button, so it won't update the value while dragging the range slider. This behavior occurs in all browsers, including Firefox, Chrome, and Safari. Let's examine this problem and explore the solution using the oninput event. Problem: onchange Event Limitation In this example, the range ...
Read More