Pankaj Kumar Bind

Pankaj Kumar Bind

33 Articles Published

Articles by Pankaj Kumar Bind

33 articles

How to set an equivalent of the \"cover\" Value of the background-size Property for an img Tag?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 16-Mar-2026 1K+ Views

When creating responsive images in web design, a common requirement is to make the image fill the entire container while preserving its aspect ratio. The CSS background-size: cover; property achieves this effect for background images, but for inline images using the tag, we need a different approach. The object-fit property provides an equivalent solution for elements. Syntax Following is the syntax for using object-fit on an element − img { width: 100%; height: 100%; object-fit: cover; } For comparison, ...

Read More

How to Convert URL Parameters to JSON in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 2K+ Views

When working with URLs you will often encounter query parameters that add additional information to the base URL. It may be helpful for developers whenever they need to convert these URL parameters to JSON format, especially for reading and manipulating data. Here we will explore different methods to convert URL parameters to a JSON format in JavaScript including built-in methods and custom solutions using split, reduce, and regular expressions. Understanding URL Parameters URL parameters (query string) follow the ? character in a URL, with each key-value pair separated by &. Here's an example URL: https://example.com/page?name=Pankaj&age=20&city=Surat ...

Read More

How to Convert XML to JSON String in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 2K+ Views

Some popular formats for data exchange are XML (eXtensible Markup Language) and JSON (JavaScript Object Notation). Tags are used to structure XML, while JSON is a more condensed key-value format. In JavaScript apps, converting XML data to JSON is often required to facilitate data manipulation or integration with APIs that expect JSON format. Several techniques for converting XML to JSON using JavaScript are examined in this article, from using DOM parsing to employing custom JavaScript solutions. Understanding XML and JSON XML Example Pankaj 20 ...

Read More

Accessing metadata from an audio files using JavaScript

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 3K+ Views

Audio files contain embedded metadata such as title, artist, album, genre, and year. This metadata is valuable for media players, music libraries, and cataloging applications. JavaScript provides several approaches to access this information, ranging from basic HTML5 audio properties to dedicated libraries for extracting ID3 tags. Approaches to Access Audio Metadata Using the HTML5 Audio Element Using Web Audio API Using ID3 Libraries (jsmediatags) Using the HTML5 Audio Element The HTML5 audio element provides basic metadata access like duration and playback information. However, it ...

Read More

How to Convert CSV File to JSON in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 2K+ Views

CSV (Comma-Separated Values) and JSON (JavaScript Object Notation) are two popular data formats. CSV is ideal for tabular data storage, while JSON is widely used in web applications. Converting CSV to JSON in JavaScript is a common requirement when working with data manipulation and API integrations. Understanding CSV and JSON Formats CSV Format: Data is stored in rows with values separated by commas. Each row represents a record, and the first row typically contains column headers. name, age, city Pankaj, 20, Surat Neeraj, 18, Raipur JSON Format: Data is represented as an array of ...

Read More

How to Convert JavaScript Class to JSON in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 635 Views

JavaScript classes serve as blueprints for creating objects with properties and methods. When working with APIs or data storage, you often need to convert class instances to JSON format for serialization. This article demonstrates several approaches to convert JavaScript classes to JSON with practical examples. Approaches to Convert JavaScript Class to JSON Using JSON.stringify() Method Adding a Custom toJSON() Method Using Object.assign() Method Using Custom Serializer Using JSON.stringify() Method JSON.stringify() is the most straightforward method to convert a class ...

Read More

How to Run cmd.exe with parameters from JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 2K+ Views

Running cmd.exe with parameters from JavaScript typically involves using Node.js because standard JavaScript running in the browser does not have access to the system's command line for security reasons. With Node.js, you can use the child_process module to execute cmd.exe or any command with parameters. Approaches to Run cmd.exe with Parameters Using Node.js to Run cmd.exe with Parameters Passing Parameters Dynamically Using Spawn for Advanced Scenarios Using Node.js to Run cmd.exe with Parameters The exec function from the child_process module is the simplest ...

Read More

How to Deep Merge Two Objects in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 1K+ Views

In JavaScript, a deep merge of two objects means creating a new object by combining properties recursively, including nested objects. Unlike a simple merge, it ensures that no nested properties are lost during the merge, which only replaces top-level properties. In this article, we will look at several ways of performing a deep merge of two objects, with code and explanations. Approaches to Deep Merge Manual Recursive Function Using Lodash's merge Method Using the Spread Operator with Recursion Using Object.assign with Recursion ...

Read More

How to Convert JSON to Excel in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 3K+ Views

Converting JSON data to Excel format is a common requirement in web applications, especially for data export and reporting functionality. Excel files are widely used for data presentation and analysis, making JSON-to-Excel conversion essential for seamless data management. This article explores different methods to convert JSON data to Excel files using JavaScript, including library-based approaches and manual techniques. Approaches to Convert JSON to Excel in JavaScript Using the SheetJS (xlsx) library Manual HTML Table Export Exporting JSON to CSV format Using the SheetJS ...

Read More

How to Create Protected Object Properties in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 1K+ Views

JavaScript does not have built-in access modifiers like other languages, but we can create protected object properties using closures and WeakMap. Protected properties are accessible only through specific methods and cannot be directly accessed from outside the object, providing encapsulation and data security. Approaches to Create Protected Object Properties Using Closures Using WeakMap Using Private Fields (ES2022) Using Closures Closures create a private scope where variables are accessible only to inner functions, effectively protecting properties from external access. function ProtectedObject(name, age) ...

Read More
Showing 1–10 of 33 articles
« Prev 1 2 3 4 Next »
Advertisements