Mayank Agarwal

Mayank Agarwal

307 Articles Published

Articles by Mayank Agarwal

Page 7 of 31

How to get Property Descriptors of an Object in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 291 Views

In JavaScript, property descriptors define the behavior and characteristics of object properties. The Object.getOwnPropertyDescriptor() method returns a descriptor object that describes a specific property of an object, including its value and configuration attributes. Syntax Object.getOwnPropertyDescriptor(obj, prop) Parameters obj − The object whose property descriptor you want to retrieve. prop − The name or Symbol of the property whose descriptor you want to retrieve. This method returns a property descriptor object if the property exists, or undefined if it doesn't. Property Descriptor Attributes A ...

Read More

crypto.scrypt() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 882 Views

The crypto.scrypt() method provides an asynchronous implementation of the scrypt password-based key derivation function. Scrypt is designed to be computationally expensive and memory-intensive, making it resistant to brute-force attacks by requiring significant resources to compute. Syntax crypto.scrypt(password, salt, keylen, [options], callback) Parameters The parameters are described below: password – The password to derive a key from. Can be a string, Buffer, TypedArray, or DataView. ...

Read More

Decipher.final() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 435 Views

The decipher.final() method in Node.js is used to return the remaining decrypted data from a decipher object. It is part of the crypto module's Decipher class and must be called to complete the decryption process. Once called, the decipher object cannot be used to decrypt additional data. Syntax decipher.final([outputEncoding]) Parameters outputEncoding – Optional. The encoding format for the output. Possible values include 'utf8', 'hex', 'base64', etc. If not specified, a Buffer is returned. Return Value Returns a Buffer or string containing the final decrypted data, depending on whether outputEncoding is ...

Read More

decipher.update() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 459 Views

The decipher.update() method is used to decrypt encrypted data incrementally in Node.js. It processes encrypted data according to specified encoding formats and is part of the Decipher class within the crypto module. Syntax decipher.update(data, [inputEncoding], [outputEncoding]) Parameters data – The encrypted data to be decrypted. Can be a string or Buffer depending on inputEncoding. inputEncoding – (Optional) The encoding of the input data. Common values: 'hex', 'base64'. If omitted, data is treated as a Buffer. outputEncoding – (Optional) The encoding for ...

Read More

Creating Animated Counter using HTML, CSS, and JavaScript

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 19K+ Views

An animated counter is a display that smoothly transitions from one number to another, typically starting from 0 and counting up to a target value. This creates an engaging visual effect commonly used in dashboards, statistics displays, and landing pages. In this article, we'll create an animated counter using HTML for structure, CSS for styling, and JavaScript for the animation logic. Steps for Creating Animated Counter Follow these steps to build the animated counter: Create two div elements: one container for styling and one to display the counter value. ...

Read More

process.argv() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 5K+ Views

The process.argv property returns an array containing command-line arguments passed when the Node.js process was launched. The first element is the path to the Node.js executable, and the second is the path to the JavaScript file being executed. Syntax process.argv Parameters process.argv is a property, not a method, so it doesn't take any parameters. It automatically captures all command-line arguments passed to the Node.js process. Basic Usage Example Create a file named argv.js and run it using the command node argv.js: // Node.js program to demonstrate the use of process.argv ...

Read More

How to Ping a Server using JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 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. JavaScript Limitations for True ICMP Ping JavaScript in web browsers cannot perform ...

Read More

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

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 6K+ Views

In this article, we will explore how to use event listeners to control video playback with mouse interactions. We'll use the mouseover and mouseout events to automatically play and pause a video when the user hovers over it. The main functionality includes playing the video whenever the mouse hovers over the video element and pausing the video when the mouse leaves the video area. How It Works We attach event listeners to a video element in the DOM. When the browser detects a mouseover event, it triggers a JavaScript function to play the video. Similarly, when a ...

Read More

process.chdir() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 7K+ Views

The process.chdir() method changes the current working directory of the Node.js process. It throws an exception if the operation fails (such as when the specified directory doesn't exist) but returns no value on success. Syntax process.chdir(directory) Parameters directory – A string containing the path to the directory you want to change to. Return Value This method returns undefined on success and throws an error if the directory change fails. Example 1: Successful Directory Change // Node.js program to demonstrate process.chdir() const process = ...

Read More

process.cpuUsage() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 1K+ Views

The process.cpuUsage() method returns CPU time consumption information for the current Node.js process. It provides data about user and system CPU time in microseconds (10^-6 seconds). Syntax process.cpuUsage([previousValue]) Parameters previousValue – Optional parameter. A previous return value from calling process.cpuUsage() to calculate the difference in CPU usage. Return Value Returns an object with two properties: user – CPU time spent in user code (microseconds) system – CPU time spent in system calls (microseconds) Example: ...

Read More
Showing 61–70 of 307 articles
« Prev 1 5 6 7 8 9 31 Next »
Advertisements