Found 6710 Articles for Javascript

How to Create Horizontal and Vertical Tabs using JavaScript?

Rushi Javiya
Updated on 07-Mar-2023 11:01:08

1K+ Views

We can create tabs using HTML, CSS & JavaScript. There can be two types of tabs. One is horizontal tabs, and another is vertical tabs. The tabs allow us to show different contents in very less space as we can show the different content according to the different tabs. We will learn to create horizontal and vertical tabs from scratch using HTML, CSS, and JavaScript. Create horizontal tabs We can show all tabs in a single row by creating horizontal tabs. Also, we can show the content of the selected tab below all tabs. Syntax Users can follow the syntax ... Read More

How to create Hamburger Menu for mobile devices?

Rushi Javiya
Updated on 07-Mar-2023 10:55:12

1K+ Views

The hamburger menu icon has three vertical bars, which the navbar uses to expand and collapse the menu on mobile and tablet devices. This tutorial will teach us to create a hamburger menu from scratch. Here, we will use HTML, CSS, JavaScript, and Bootstrap to create a stylish hamburger menu with a navbar. Steps Users can follow the steps below to create a navbar with a hamburger menu icon. Step 1 − Create a div with a container class containing a navbar and an expandable menu. Step 2 − After that, create a div with a header class inside ... Read More

How to use Typescript with native ES6 Promises?

Shubham Vora
Updated on 06-Mar-2023 15:04:56

2K+ Views

In the ES6 version of ECMAScript, promises are introduced for the first time. To use the ES6 promises in the TypeScript project, users need to modify the tsconfig.json file. Add the below code inside the ‘compilerOptions’ object. { "compilerOptions": { "target": "es6", } } Also, users can add ‘ES6’ inside the ‘lib’ property, as shown below. { "compilerOptions": { "lib": [ "es6", ... Read More

How to use Selenium Web Driver and JavaScript to Login any website?

Shubham Vora
Updated on 07-Mar-2023 14:08:52

2K+ Views

Nowadays, automation is very useful for testing the application. Many automation tools are available, and Selenium is one of them, developed in 2004. Also, it is a crossplatform tool, so we can use Selenium with most programming languages, and here we will use it with JavaScript. Users need to create the NodeJS application to use the Selenium web driver with JavaScript. Create a NodeJS Application Users can follow the steps below to create a NodeJS application. Step 1 – Open the project directory in the terminal and enter the below command. npm init -y Step 2 – ... Read More

How to use Regex to get the string between curly braces using JavaScript?

Shubham Vora
Updated on 06-Mar-2023 14:52:37

6K+ Views

We can create a regular expression so it can find all the substrings between the curly braces. After that, we can use the exec() or match() method to extract the matching substring. In this tutorial, we will learn to use a regular expression to get the string between curly braces using JavaScript. For example, if we have given a string like ‘This is a {string} with {curly} braces, we need to extract all substrings that reside between the curly braces. Using the exec() method with a regular expression to get the string between curly braces The exec() ... Read More

How to use Particle.js in JavaScript project?

Shubham Vora
Updated on 06-Mar-2023 12:43:35

2K+ Views

As the name suggests, the Particle.js library allows us to add particles to a particular HTML element. Also, we can change the shape of the particles number of particles in the div. We can add animation or motion to particles using the Particle.js library. Here, we will learn to change the shape, colour, and motion of particles via different examples. Syntax Users can follow the syntax below to use the Particle.js library in a JavaScript project. tsParticles.load("id", { particles: { // properties for the ... Read More

Javascript Program to Count Pairs with Given Sum

Ravi Ranjan
Updated on 06-Jun-2025 19:17:34

1K+ Views

To count pairs with given sum, is a common problem asked in job interviews and is often used in many real-world applications such as cryptography and data compression. In this article we are having an array and a target sum value, our task is to write a Javascript program to count pairs with given sum. Example Input: arr = [1, 2, 3, 5, 6, 7, 9] sum = 8 Pairs = (1, 7), (2, 6), (3, 5) Output: Count: 3 Approaches to Count Pairs with Given Sum Here is a list of ... Read More

Javascript Program to Count 1’s in a sorted binary array

Prerna Tiwari
Updated on 06-Mar-2023 11:56:21

413 Views

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 blog post, 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 ... Read More

How to create a new object from the specified object, where all the keys are in lowercase in JavaScript?

Prerna Tiwari
Updated on 06-Mar-2023 11:41:42

2K+ Views

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 More

How to create a JavaScript callback for knowing if an image is loaded?

Prerna Tiwari
Updated on 06-Mar-2023 11:34:54

2K+ Views

Strong programming languages like JavaScript are frequently used to build interactive, dynamic web pages. The loading of images on a website is one of JavaScript's most popular uses. However, loading images might be challenging, particularly when determining whether a load is complete. In this article, we'll go through how to make a JavaScript callback that detects if an image has loaded or not. What is a callback function? A callback function is a function that is invoked after the initial function has finished running and is supplied as an argument to another function. To put it another way, a ... Read More

Advertisements