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 240 of 534
How to create a new object from the specified object, where all the keys are in lowercase in JavaScript?
There are many methods for creating new objects from older ones in JavaScript. Creating a new object with the same keys as an existing object but with all the keys in lowercase is a common use case. When working with data from many sources that have irregular key casing, this can be helpful. We'll look at various JavaScript ways to create new objects with lowercase keys in this blog post. However, before doing so, it's important to remember that while creating a new object with lowercase keys might be helpful when working with data from various sources, it's also ...
Read MoreJavascript Program to Count 1's in a sorted binary array
We have two approaches to count 1's in a sorted binary array. The first one is to iterate through the array and count the 1's. The second approach is to use a binary search algorithm to find the first occurrence of 1 in the array. It is important to note that in order to use these approaches, the array must be sorted. In this article, we will discuss a JavaScript program to count the number of 1's in a sorted binary array. We will also look at some edge cases and optimization techniques to make the program more ...
Read MoreHow to use Particle.js in JavaScript project?
Particle.js is a JavaScript library that creates stunning visual effects by adding animated particles to HTML elements. You can customize particle shapes, colors, motion, and interactions to enhance your web projects with dynamic backgrounds and visual effects. This library is perfect for creating engaging landing pages, interactive backgrounds, and modern web interfaces with floating particles that respond to user interactions. Syntax The basic syntax to initialize particles using the tsParticles library: tsParticles.load("elementId", { particles: { // Configuration options for particles ...
Read MoreHow to use Regex to get the string between curly braces using JavaScript?
We can create a regular expression to find all substrings between curly braces and use methods like exec() or match() to extract them. In this tutorial, we will learn to use regular expressions to get strings between curly braces in JavaScript. For example, from the string 'This is a {string} with {curly} braces', we need to extract "string" and "curly". Using the exec() Method with Regular Expression The exec() method finds matched substrings and returns results in array format. It returns null if no matches are found. Syntax var regex = /{([^}]+)}/g; while (match ...
Read MoreHow to create Hamburger Menu for mobile devices?
The hamburger menu icon has three horizontal bars that expand and collapse navigation menus on mobile and tablet devices. This tutorial teaches you to create responsive hamburger menus using HTML, CSS, JavaScript, and Bootstrap. We'll cover two approaches: a custom implementation from scratch and a Bootstrap-based solution for faster development. Creating a Custom Hamburger Menu Follow these steps to build a hamburger menu without external libraries: Step 1 − Create a container div with navbar and expandable menu sections. Step 2 − Add a header div containing the menu icon and logo/text elements. Step 3 ...
Read MoreHow to use Selenium Web Driver and JavaScript to Login any website?
Nowadays, automation is very useful for testing applications. Many automation tools are available, and Selenium is one of them, developed in 2004. Also, it is a cross-platform tool, so we can use Selenium with most programming languages, and here we will use it with JavaScript. Users need to create a Node.js application to use the Selenium WebDriver with JavaScript. Setting Up Node.js Application Follow these steps to create a Node.js application for Selenium automation: Step 1: Initialize a new Node.js project npm init -y Step 2: Install the Selenium WebDriver package ...
Read MoreComputing the Cartesian Product of Two Sets in JavaScript
In set theory, a Cartesian product is a mathematical operation that returns a set from multiple sets. For sets A and B, the Cartesian product A × B is the set of all ordered pairs (a, b) where a ∈ A and b ∈ B. We need to write a JavaScript function that takes two arrays representing distinct sets and returns a 2-D array containing their Cartesian product. What is Cartesian Product? The Cartesian product creates all possible combinations between elements of two sets. If set A has m elements and set B has n elements, the ...
Read MoreHow to setup Video.js with JavaScript?
In this tutorial, we're going to learn how to set up Video.js using JavaScript. We'll also have a look at a few examples for better understanding. Video.js is a popular and easy-to-use modern web video player built on HTML5. It provides enhanced features and functionality for web video players, supporting various video formats including standard HTML5 formats and modern formats like YouTube, Vimeo, and Flash. It works seamlessly across all display sizes including desktops and mobile devices. Installing Video.js Video.js is officially available through CDN and npm (node package manager). Let's look at both installation methods. ...
Read MoreCreate a to-do list with JavaScript
A TODO list is a simple application that helps users keep track of tasks they need to complete. It typically allows users to add new tasks, mark them as completed, edit existing tasks, and delete unnecessary ones. In this tutorial, we'll learn how to create a functional to-do list using JavaScript. Our to-do list will support the following core features: Add new tasks Delete tasks Mark tasks as completed Edit existing tasks Basic To-Do List Implementation Let's start with a simple example ...
Read MoreApply an IF condition to every element in an HTML table with JavaScript?
HTML tables are created using the tag with for table rows and for data cells. JavaScript allows you to apply conditional logic to each table element dynamically. This article demonstrates how to use JavaScript to apply if conditions to every element in an HTML table, enabling dynamic content modification based on specific criteria. Using document.querySelectorAll() with forEach() The document.querySelectorAll() method returns a static NodeList of all elements matching the specified CSS selector. Combined with forEach(), it allows you to iterate through table elements and apply conditions. Syntax document.querySelectorAll(selector).forEach(function(element) { ...
Read More