Mayank Agarwal

Mayank Agarwal

307 Articles Published

Articles by Mayank Agarwal

Page 6 of 31

crypto.getCurves() Method in Node.js

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

The crypto.getCurves() method returns an array containing names of all supported elliptic curves in Node.js. These curves are used for creating Elliptic Curve Diffie-Hellman (ECDH) key exchange objects for secure cryptographic operations. Syntax crypto.getCurves() Parameters This method takes no parameters since it returns a complete list of all available elliptic curves. Return Value Returns an array of strings, where each string represents the name of a supported elliptic curve. Example Here's how to use crypto.getCurves() to retrieve all available elliptic curves: // Importing the crypto module const crypto ...

Read More

How to Detect if CAPS Lock is ON using JavaScript?

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

In this article, we are going to explore the CAPS LOCK key and how to check if it is turned on or not using JavaScript on a webpage. While working with modern web applications, we often require information about user interaction and experience. The user interacts with a website to execute functionality like hitting an API, handling clicks or buttons that trigger methods, and many more. In some cases, we might need to know whether the CAPS LOCK key is turned on or not. One use case can be any authentication system that notifies the user that the ...

Read More

JavaScript: How to Detect if a Website is Open on a Mobile or a Desktop?

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

We can use the CSS media queries to check whether the website is opened inside a web browser or a mobile browser. This information can be fetched using the min-width and the max-width of the webpage. CSS media queries are only limited to styling the web pages but we can control the functionality of a website as per the user's device by using the navigator properties in JavaScript. The Navigator returns a set of values that includes user browser, version, operating system, and many more. Syntax navigator.userAgent Method 1: Using navigator.userAgent In ...

Read More

crypto.getHashes() Method in Node.js

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

The crypto.getHashes() method returns an array containing the names of all supported hash algorithms available in Node.js. This is useful for discovering what hashing options are available in your current Node.js environment. Syntax crypto.getHashes() Parameters This method takes no parameters and returns an array of supported hash algorithm names. Return Value Returns an array of strings, where each string is the name of a supported hash algorithm. Example // Importing the crypto module const crypto = require('crypto'); // Get all supported hash algorithms const hashAlgorithms = crypto.getHashes(); ...

Read More

How to Disable Radio Buttons using JavaScript?

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

A radio button is an input type that allows users to select one option from multiple choices. In web forms, you may need to disable radio buttons dynamically based on user interactions or specific conditions. In this article, we will explore how to disable and enable radio buttons using JavaScript. We'll cover the disabled property and demonstrate practical examples where radio buttons are conditionally disabled. The disabled Property JavaScript provides the disabled property to control whether form elements are interactive. This boolean property can be set to true to disable an element or false to enable it. ...

Read More

crypto.privateDecrypt() Method in Node.js

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

The crypto.privateDecrypt() method is used for decrypting data that was previously encrypted using the corresponding public key with crypto.publicEncrypt(). This method is essential for implementing asymmetric encryption in Node.js applications. Syntax crypto.privateDecrypt(privateKey, buffer) Parameters The method accepts the following parameters: privateKey – Can be an Object, String, Buffer, or KeyObject containing: oaepHash – Hash function for OAEP padding and MGF1. Default: 'sha1' oaepLabel – Label for OAEP padding. ...

Read More

How to encode and decode a URL in JavaScript?

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

Encoding and decoding URLs is essential in web development for handling special characters in URLs. When making GET requests to APIs with query parameters, proper encoding ensures URLs are transmitted correctly. Browsers often handle this automatically, but understanding these methods is crucial. For example, a space " " is encoded as %20 or + depending on the context. Understanding URL Encoding Methods JavaScript provides two main functions for URL encoding: encodeURI() − Encodes a complete URI while preserving URL structure characters like :, /, ?, #, &, = encodeURIComponent() ...

Read More

crypto.randomFill() Method in Node.js

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

The crypto.randomFill() method in Node.js fills an existing buffer with cryptographically strong random data. Unlike crypto.randomBytes() which creates a new buffer, randomFill() fills a provided buffer with random data. Syntax crypto.randomFill(buffer, [offset], [size], [callback]) Parameters buffer – The buffer to be filled. Supported types: Buffer, TypedArray, ArrayBuffer, DataView. Maximum size is 2**31-1. offset – Starting position for filling (optional). Default is 0. size – Number of bytes to fill from the offset (optional). Default is buffer.length - offset. callback – Function called when operation completes or errors occur (optional). Example: Basic ...

Read More

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

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

In this article, we will explore how JavaScript strings can exist as literals or objects, and learn methods to distinguish between them. In JavaScript, strings can exist in two forms: String Literal: Created using quotes (', ", or `) String Object: Created explicitly using the String constructor with new String("text") Understanding String Literals vs String Objects String literals are primitive values, while String objects are wrapper objects around the primitive string value. This distinction affects how they behave with certain operators and methods. Using typeof to Check String ...

Read More

crypto.randomFillSync() Method in Node.js

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

The crypto.randomFillSync() method takes a buffer argument and returns the buffer by filling it with its encrypted value. As the name suggests, this will be a sync process. Syntax crypto.randomFillSync(buffer, [offset], [size]) Parameters The above parameters are described as below − buffer – This field contains the data content. Possible buffer types are: string, TypedArray, Buffer, ArrayBuffer, DataView. The size of the buffer cannot be greater than 2**31-1. ...

Read More
Showing 51–60 of 307 articles
« Prev 1 4 5 6 7 8 31 Next »
Advertisements