Found 10483 Articles for Web Development

How to Ping a Server using JavaScript?

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

8K+ 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 sends a PONG that shows that the server is active. Ping messages are sent by the ICMP (Internet Control Messaging Protocol). The lower the ping time the stronger the connection between the host and the server.ApproachWe can use a JavaScript function for sending the Ping messages to the server. In ... Read More

JavaScript: How to map array values without using \"map\" method?

Disha Verma
Updated on 25-Feb-2025 14:51:59

1K+ Views

Mapping array values without using the map method can be done by using forEach() method, reduce() method, for loop, and while loop. In this article, we will implement some methods that will work efficiently for mapping array values. Table of Content Mapping array values without using map method can be done in the following ways: Using forEach() Using reduce() Using a for Loop Using while Loop Using forEach() The forEach() method allows you to iterate through each element in ... Read More

Creating Animated Counter using HTML, CSS, and JavaScript

Mayank Agarwal
Updated on 01-Oct-2024 10:39:15

19K+ Views

To create animated counter, we will be using HTML, CSS and Javascript. An animated counter can be described as a display that counts an animation starting from 0 and ending at a specific number. In this article, the initial value of counter is set to 0, our task is to create animated counter using HTML, CSS, and JavaScript. Steps for Creating Animated Counter We will be follwoing below mentioned steps to create animated counter. We have used two div where one div will display the output i.e counter and other div acts as a container. ... Read More

How to Handle JavaScript Events in HTML?

Mayank Agarwal
Updated on 26-Apr-2022 10:16:07

1K+ Views

An Event is basically defined as an action or occurrence of an action that is recognized by the software. An Event can be triggered by any of the following: a user, a system, or a remote callback. Some of the popular events include pressing a button, hovering, clicking on hyperlinks, etc.In this article, we will be exploring some commonly used JavaScript events and learning how to handle these events and execute the required tasks. To handle events in HTML, we would need to add the function in the HTML tag that will be required to be executed in JavaScript when ... Read More

How to get Property Descriptors of an Object in JavaScript?

Mayank Agarwal
Updated on 26-Apr-2022 10:06:02

235 Views

In this article, we are going to explore property descriptors and how we can fetch these values from an object. The Object.getOwnPropertyDescriptor method returns an object that describes the specific property from the given object. A JavaScript object can be created in multiple ways that can be called by using the property descriptors from the object.SyntaxObject.getOwnPropertyDescriptor(obj, propThe property descriptor takes two parameters as inputs that are described below −obj − The object refers to the object name whose properties need to be described.prop − It defines the specific property from the object whose value needs to be returned.This method returns ... Read More

JavaScript: How to Check if a String is a Literal or an Object?

Mayank Agarwal
Updated on 09-Dec-2024 21:56:22

2K+ Views

In this article, we will be exploring strings and how they can be used as a literal and an object depending on the requirements. In JavaScript, strings can exist in two forms: String Literal: Created using quotes (', ", or `).String Object: Created explicitly using the String constructor, e.g., new String("text"). JavaScript Literals A JavaScript literal can be referred to as representing fixed values in source code. In most languages, values are denoted by Integers, floating-point numbers, strings, boolean, characters, arrays, records, and many more. JavaScript Objects On the other hand, a JavaScript object can be defined as a list of ... Read More

JavaScript: How to Find Min/Max Values Without Math Functions?

Mayank Agarwal
Updated on 26-Apr-2022 08:49:27

2K+ Views

In this article, we will explore how to find the minimum and maximum values from an array without using the Math functions. Math functions including Math.min() and Math.max() returns the minimum and maximum values out of all the numbers passed in the array.ApproachWe are going to use the same functionality of the Math functions that can be implemented using a loop.This will iterate over the array elements using the for loop and will update the minimum and maximum element in a variable after comparing it with each element from the array.On finding the value greater than the max value we ... Read More

JavaScript: How to filter out Non-Unique Values from an Array?

Disha Verma
Updated on 25-Feb-2025 14:51:10

1K+ Views

To filter out non-unique values from an array in JavaScript, you can use the filter() method, a for loop, the set and filter() method, and the reduce() method. In this article, we will filter out non-unique values and return an array that only contains unique non-repeating elements. Arrays are data structures used to store data in a structured format. We can store the data in an array and retrieve them using their indexes. These indexes serve as a key for these values. Table of Content Filtering non-unique values from an array can be done in the following ways: ... Read More

How to encode and decode a URL in JavaScript?

Mayank Agarwal
Updated on 26-Apr-2022 08:32:31

6K+ Views

Encoding and decoding the URI and the URI components is required by the URL of any website to reach or redirect the user. It is a usual task in web development, and this is generally done while making a GET request to the API with the query params. The query params must also be encoded in the URL string, where the server will decode this. Many browsers automatically encode and decode the URL and the response string.E.g., A space " " is encoded as a + or %20.Encoding a URLThe conversion of the special characters can be done by using ... Read More

How to Disable Radio Buttons using JavaScript?

Mayank Agarwal
Updated on 26-Apr-2022 08:06:53

2K+ Views

A radio button is an input type that takes input in form of the options. The user will select one value from multiple choices. Only one option can be selected out of many possible choices.In this article, we will explore how to disable a radio button and how to enable it back when required. We will see how radio buttons work internally and how can we disable them when requiredMostly radio buttons are shown to the user only in some cases as part of confirmation. When not required we can disable them so that the user does not choose an ... Read More

Advertisements