Articles on Trending Technologies

Technical articles with clear explanations and examples

How to remove CSS property using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 22K+ Views

To remove CSS properties using JavaScript, you can clean up unnecessary styles, improve performance, make code easier to maintain, and simplify debugging. In this article, we'll explore different methods to remove CSS properties from HTML elements using JavaScript. We'll work with div and p elements that have various CSS properties applied. Approaches to Remove CSS Properties Here are five effective methods to remove CSS properties using JavaScript: Using the removeProperty() Method Using the setProperty() Method Using null Value Using ...

Read More

JavaScript program to remove vowels from a string

AYUSH MISHRA
AYUSH MISHRA
Updated on 15-Mar-2026 807 Views

A string is a sequence of characters that can include alphabets, numbers, and symbols together or separately. In this article, we are going to learn how we can remove vowels from a given string in JavaScript using different approaches. The five vowels in the English alphabet are: a, e, i, o, u, and they can be both uppercase or lowercase. Problem Examples Example 1 Input: Anshu Ayush Output: nsh ysh Explanation The vowels in the string "Anshu Ayush" are A, u, A, u. After removing them, the remaining string is "nsh ysh". Example ...

Read More

How to replace an HTML element with another one using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 18K+ Views

In this tutorial, we will learn to replace an HTML element with another one using JavaScript. In some use cases, we require to replace a whole HTML element with a different one. For example, it is very important in form validation. Suppose we are taking the user's age from the form, and the user enters the wrong age; we can show the validation message by replacing the HTML element. Another use case where we require to replace an HTML element with another one is dynamic content loading, in which we must show the web page content based on certain ...

Read More

Explain the MUL() function in JavaScript

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 913 Views

In this tutorial, we will learn to implement the MUL() function in JavaScript. This function demonstrates multiplication using nested functions, which create closures that maintain access to outer function variables. The MUL() function showcases JavaScript's first-class function nature, where functions can be returned from other functions. There are two ways to implement the MUL() function using nested functions: Using nested functions with names Using function currying with anonymous functions Using Nested Functions With Names In JavaScript, we can use nested functions to create a multiplication function that takes arguments one at a time. Each ...

Read More

How to Convert JavaScript Class to JSON in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 649 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

Difference Between String Slice and Substring Methods

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 2K+ Views

JavaScript provides several built-in methods for string manipulation. Two commonly used methods are slice() and substring(), which extract portions of strings. While they appear similar, they handle edge cases differently, particularly with negative indices. String slice() Method The slice() method extracts a section of a string and returns it as a new string without modifying the original string. Syntax string.slice(start, end) Parameters start: The index where extraction begins (inclusive) end (optional): The index where extraction ends (exclusive) String substring() Method The substring() method ...

Read More

How to Catch a ReferenceError with onerror?

Aayush Mohan Sinha
Aayush Mohan Sinha
Updated on 15-Mar-2026 230 Views

JavaScript's onerror event provides a global way to catch errors, including ReferenceErrors, that occur during script execution. This is particularly useful for handling errors that might not be caught by traditional try-catch blocks. What is ReferenceError? A ReferenceError occurs when trying to access a variable or object that doesn't exist. This commonly happens with misspelled variable names or accessing variables before they're declared. Example of ReferenceError try { ...

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 Catch all JavaScript Errors and Send them to the Server?

Aayush Mohan Sinha
Aayush Mohan Sinha
Updated on 15-Mar-2026 556 Views

JavaScript error handling is crucial for maintaining robust web applications. The window.onerror event allows you to catch all JavaScript errors globally and send them to your server for monitoring and debugging purposes. Understanding window.onerror The window.onerror event fires whenever an uncaught JavaScript error occurs in your application. It provides detailed information about the error including location and error details. Syntax window.onerror = (message, source, lineno, colno, error) => { // Handle error }; Parameters message: A string containing the error message that describes ...

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
Showing 14131–14140 of 61,297 articles
Advertisements