Mayank Agarwal

Mayank Agarwal

307 Articles Published

Articles by Mayank Agarwal

Page 9 of 31

Stream writable.cork() and uncork() Method in Node.js

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

The writable.cork() method is used for forcing all written data to be buffered in memory. This buffered data will only be flushed when stream.uncork() or stream.end() methods are called. These methods are useful for optimizing performance by batching multiple write operations. Syntax cork() writable.cork() uncork() writable.uncork() Parameters Both methods take no parameters. The cork() method buffers subsequent write operations, while uncork() flushes the buffered data to the underlying destination. How It Works When cork() is called, all subsequent write operations are buffered in memory instead of being ...

Read More

How to swap variables using Destructuring Assignment in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 337 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 code. This assignment lets the expression unpack values from arrays, and properties into distinct variables. One of the most elegant use cases is swapping variables without using a temporary variable. Traditional Variable Swapping Before destructuring, swapping variables required a temporary variable: Traditional Variable Swap ...

Read More

Stream writable.writableLength Property in Node.js

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

The writable.writableLength property returns the number of bytes (or objects) in the queue waiting to be written. This property is useful for monitoring buffer status and understanding the backpressure in your writable streams. Syntax writable.writableLength How It Works The property counts data that is: Buffered in the internal queue Waiting to be processed by the _write() method Corked (temporarily held) in memory Data that has already been written or is currently being processed is not counted. Example 1: Basic Usage with Cork Create a file named writableLength.js and run ...

Read More

Stream writable.writableObjectMode Property in Node.js

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

The writable.writableObjectMode property is used to check whether a writable stream is operating in object mode. It returns true if object mode is enabled, false if disabled, or undefined if not explicitly set. Syntax writable.writableObjectMode Return Value Returns a boolean value or undefined: true - Object mode is enabled false - Object mode is explicitly disabled undefined - Object mode not set (default) Example 1: Stream with Object Mode Enabled // Program to demonstrate writable.writableObjectMode property // Importing the stream module const stream = require('stream'); // Creating a ...

Read More

How to use Static Variables in JavaScript?

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

The keyword "static" is used for defining static methods or properties of a class in JavaScript. Static members belong to the class itself rather than to instances of the class, meaning you can access them without creating an object. Static variables maintain a single value that is shared across all instances of the class. Unlike instance variables, static variables are initialized when the class is first loaded and retain their value throughout the program's execution. Note − Static variables can be reassigned and modified, unlike const variables which are immutable after initialization. Syntax class ClassName ...

Read More

How to use the "in" operator in JavaScript?

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

In this article, we are going to explore the 'in' operator and how to use it in JavaScript. The in operator is an inbuilt operator in JavaScript that is used for checking whether a particular property exists in an object or not. It will return true if the property exists, else false is returned. Syntax prop in object Parameters This operator accepts the following parameters as described below − prop − This parameter holds the string or symbol that represents a property ...

Read More

How to Delete a Linked List in JavaScript?

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

In this article, we are going to explore Linked List and how to delete a linked list in JavaScript. A Linked List is a linear data structure where elements are not stored in contiguous memory locations. Each element (called a node) contains data and a pointer/reference to the next node in the sequence. ...

Read More

What are JavaScript Classes and Proxies?

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

JavaScript Classes and Proxies are powerful ES6+ features that enhance object-oriented programming and metaprogramming capabilities. Classes provide a cleaner syntax for creating objects and implementing inheritance, while Proxies allow you to intercept and customize operations on objects. JavaScript Classes Classes in JavaScript are syntactic sugar over the existing prototype-based inheritance. They use the class keyword instead of functions and must be declared before use, unlike function declarations which are hoisted. Class Declaration Syntax class ClassName { constructor(property1, property2) { this.property1 = property1; ...

Read More

What are JavaScript Factory Functions?

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

A factory function is a function that creates and returns an object. Unlike constructor functions, factory functions don't require the new keyword and don't use this to reference object properties. Factory functions are a simple and flexible way to create objects in JavaScript. They can include properties, methods, and default values, making object creation more convenient and reusable. Key Features Factory functions offer several advantages: No need for the new keyword No this binding issues Can contain private variables through closures Return objects directly Allow for easy object customization Basic Syntax ...

Read More

What are the Important Array Methods in JavaScript?

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

In this article, we are going to explore different methods provided by Array and their importance in JavaScript. We will learn how to use them and what are their actual use cases with the help of examples. Before moving on to methods, below is the syntax for creating an array in JavaScript: let array = [element1, element2, ...]; Alternatively, we can also define the array as follows: let array = new Array(element1, element2, ...); Basic Array Methods (Adding/Removing Elements) These methods are essential for manipulating array contents: ...

Read More
Showing 81–90 of 307 articles
« Prev 1 7 8 9 10 11 31 Next »
Advertisements