Mayank Agarwal has Published 410 Articles

How to use JavaScript to play a video on Mouse Hover and pause on Mouseout?

Mayank Agarwal

Mayank Agarwal

Updated on 27-Apr-2022 09:53:24

5K+ Views

In this article, we will be exploring the event listeners and how to use them for pausing and playing a video. We will be using the mouse over and the mouseout events to control the video.The main element of this article includes playing the video whenever the mouse hovers over ... Read More

How to Ping a Server using JavaScript?

Mayank Agarwal

Mayank Agarwal

Updated on 27-Apr-2022 09:47:12

6K+ Views

A server ping can be defined as hitting a server and getting a response in return from that server. The idea is to send an echo message that will keep the health check and check whether the server is up and running or not. On sending a PING every server ... Read More

How to use JavaScript to replace a portion of string with another value?

Mayank Agarwal

Mayank Agarwal

Updated on 26-Apr-2022 13:24:35

760 Views

In this article, we are going to explore replacing a portion of a string with another value using JavaScript. We can replace string parts in multiple ways. Below are some common methods −replace() methodsplit() methodjoin() methodLet’s discuss the above methods in detail.The replace() MethodThis is an inbuilt method provided by ... Read More

How to swap variables using Destructuring Assignment in JavaScript?

Mayank Agarwal

Mayank Agarwal

Updated on 26-Apr-2022 13:14:16

183 Views

The Destructuring assignment is a feature that was introduced in the ECMAScript 2015. This feature lets the user extract the contents of the array, and properties of an object into distinct variables without actually writing the repetitive codeThis assignment lets the expression unpack values from arrays, and properties into distinct ... Read More

How to set the cursor to wait in JavaScript?

Mayank Agarwal

Mayank Agarwal

Updated on 26-Apr-2022 12:53:57

2K+ Views

In this article, we are going to look at some cursor settings and their behaviors. Currently, there are different kind of cursors as provided by any system that includes a pointer, hand, insert, wait, pointer-wait, and many others.With the help of this article, we would be able to configure the ... Read More

How to search a string for a pattern in JavaScript?

Mayank Agarwal

Mayank Agarwal

Updated on 26-Apr-2022 12:50:09

440 Views

In this article, we are going to search for a specific pattern and only by pass those string that matches the given pattern. We will be using the following approaches to achieve this functionality −Approach 1In this approach, we will be searching for a string that matches the given pattern ... Read More

JavaScript: How to return True if the focus is on the browser tab page?

Mayank Agarwal

Mayank Agarwal

Updated on 26-Apr-2022 12:45:59

912 Views

In this article, we are going to explore how to check if the browser tab page is focused and under use or not. This is mainly required to record the user’s inactivity time on the app and then take any action upon it if required.It can be useful in some ... Read More

How to return all matching strings against a RegEx in JavaScript?

Mayank Agarwal

Mayank Agarwal

Updated on 26-Apr-2022 12:39:51

367 Views

In this article, we will explore the essentials of a regular expression (RegEx) and how to compare other strings with this regex in JavaScript. We will learn how to identify a similar string with that of a regex and then subsequently return them. We can use the string.search() method to ... Read More

How to remove duplicate elements from an array in JavaScript?

Mayank Agarwal

Mayank Agarwal

Updated on 26-Apr-2022 12:25:42

1K+ Views

There are multiple ways of removing duplicate elements from an array in JavaScript. In this article, we are going to explore some of the top methods to remove duplicate elements.Using the filter() MethodThe filter() method creates a new array of elements with the passed condition. This will only contain the ... Read More

How to Toggle Password Visibility in JavaScript?

Mayank Agarwal

Mayank Agarwal

Updated on 26-Apr-2022 12:09:13

432 Views

In this article, we are going to hide the password with ****. The password can be shown by toggling its visibility by using a button. We will be creating a JavaScript function that will display the hidden password when the toggle button is clicked.ApproachOn clicking the toggle button the JavaScript ... Read More

Advertisements