Web Development Articles

Page 275 of 801

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

process.env() Method in Node.js

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

The process.env property in Node.js provides access to environment variables. It returns an object containing all environment variables available to the current process, making it essential for configuration management in Node.js applications. Syntax process.env Note: process.env is a property, not a method, so it doesn't require parentheses. Parameters process.env is a read-only object that doesn't accept parameters. It automatically contains all environment variables from the system where the Node.js process is running. Example: Accessing All Environment Variables Create a file named env.js and run it using: node env.js ...

Read More

Reading a text file into an Array in Node.js

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

Reading text files into arrays is a common task in Node.js applications. The built-in fs module provides both synchronous and asynchronous methods to read files and convert their content into arrays by splitting lines. Using fs.readFileSync() (Synchronous) The synchronous approach blocks code execution until the file is completely read. This method is suitable for smaller files or when you need the data immediately. // Importing the fs module const fs = require("fs"); // Function to read file and convert to array const readFileLines = filename => fs.readFileSync(filename) .toString('UTF8') .split(''); ...

Read More

script.createCachedData() Method in Node.js

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

The script.createCachedData() method in Node.js creates a code cache for VM scripts, improving performance when executing the same script multiple times. This method is part of the vm module and generates cached bytecode that can be reused. Syntax script.createCachedData() Parameters This method takes no parameters. It creates cached data from the current script instance and returns a Buffer containing the cached bytecode. Return Value Returns a Buffer object containing the cached bytecode that can be used with the cachedData option when creating new script instances. Example 1: Basic Cached Data Creation ...

Read More

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

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 764 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

Stream writable.writableLength Property in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 301 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 272 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

Creating a Simple Calculator using HTML, CSS, and JavaScript

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

A student grade calculator is a web application that takes subject grades as input and calculates the overall percentage and letter grade. This interactive tool provides instant feedback on academic performance using HTML for structure, CSS for styling, and JavaScript for calculations. The percentage calculation formula is: Percentage = (Total Marks Scored / Total Maximum Marks) × 100 How It Works The calculator follows these steps: User enters marks for different subjects through HTML input fields JavaScript function retrieves and validates the input values ...

Read More

How to create a chart from JSON data using Fetch API in JavaScript?

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

In this article, we will explore how to create a chart after fetching JSON data using JavaScript's Fetch API. We'll first fetch the data from a remote server, then use that data to create a visual chart using Chart.js library. What is the Fetch API? The Fetch API provides a modern interface for making HTTP requests and handling responses. It returns promises, making it easier to work with asynchronous data compared to older methods like XMLHttpRequest. Syntax const response = fetch(resource [, init]) Parameters resource − The URL ...

Read More

How to enable JavaScript in Chrome, Firefox, and Safari?

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

JavaScript has become an essential part of modern websites. Nearly every website requires JavaScript support to function properly. All major browsers include a setting to enable or disable JavaScript. When JavaScript is disabled, websites may not work correctly, preventing users from accessing important features and interactive elements. To ensure websites function properly, you need to enable JavaScript in your browser. Here's how to enable JavaScript in the three most popular browsers: Google Chrome Mozilla Firefox Safari Google Chrome Follow these steps to ...

Read More
Showing 2741–2750 of 8,010 articles
« Prev 1 273 274 275 276 277 801 Next »
Advertisements