Articles on Trending Technologies

Technical articles with clear explanations and examples

How to add and remove names on button click with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 3K+ Views

JavaScript allows you to dynamically add and remove names from a list using DOM manipulation methods. This functionality is commonly used in todo lists, user management interfaces, and interactive forms. HTML Structure First, we need a basic HTML structure with an input field, buttons, and a container for the names list: Add and Remove Names body { ...

Read More

Convert a string to hierarchical object - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 504 Views

Let's say, we have a special kind of string that contains characters in couples, like this: const str = "AABBCCDDEE"; console.log(str); AABBCCDDEE We are required to construct an object based on this string which should look like this: const obj = { code: "AA", sub: { code: "BB", sub: { code: "CC", ...

Read More

How to find the largest number contained in a JavaScript array?

Abhishek
Abhishek
Updated on 15-Mar-2026 12K+ Views

In this tutorial, we will learn about the different methods to find the largest number contained inside a JavaScript array. An array is a collection of different values, and we need efficient ways to identify the maximum value. There are three main approaches to find the largest number in a JavaScript array: Traversing the Whole Array Using the reduce() Method Using the Math.max() and apply() methods Using Array Traversal (For Loop) This is the most straightforward approach where we iterate through each element and compare it with the current largest value. Algorithm Steps ...

Read More

How to set the color of the text-decoration with JavaScript?

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

In this tutorial, we will learn how to set the color of the text-decoration with JavaScript. The text-decoration is a CSS property used to decorate text lines. We can decorate a line using underline, overline, line-through, or none. To set the color of the text-decoration with JavaScript, we have multiple ways, and in this tutorial, we will discuss two of them − Using the style.textDecorationColor Property Using the style.setProperty Method Using the style.textDecorationColor Property In JavaScript, the style.textDecorationColor property of an element is used to set the color ...

Read More

How to create SVG graphics using JavaScript?

Govinda Sai
Govinda Sai
Updated on 15-Mar-2026 737 Views

SVG (Scalable Vector Graphics) can be dynamically created and manipulated using JavaScript. This allows you to generate interactive graphics, charts, and animations programmatically. Creating SVG Elements with JavaScript To create SVG elements in JavaScript, use document.createElementNS() with the SVG namespace. Here's how to create a basic SVG container and add shapes: SVG with JavaScript // SVG namespace ...

Read More

Override HTML5 validation

Nancy Den
Nancy Den
Updated on 15-Mar-2026 1K+ Views

HTML5 form validation can be overridden using JavaScript by removing validation attributes or preventing the default validation behavior. This is useful when you need custom validation logic or want to bypass built-in constraints. Method 1: Using removeAttribute() The removeAttribute() method removes validation attributes like required from form elements: First Name: Remove Required ...

Read More

Usage of white-space property in CSS

radhakrishna
radhakrishna
Updated on 15-Mar-2026 110 Views

The CSS white-space property controls how whitespace characters (spaces, tabs, line breaks) are handled within an element. It determines whether text wraps, how spaces are collapsed, and whether line breaks are preserved. Syntax white-space: normal | nowrap | pre | pre-wrap | pre-line | break-spaces; White-space Values Value Spaces Collapsed? Line Breaks Honored? Text Wraps? normal Yes No Yes nowrap Yes No No pre No Yes No pre-wrap No Yes Yes pre-line Yes Yes Yes Example: Using white-space: pre ...

Read More

How to add two strings with a space in first string in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 5K+ Views

To concatenate two strings in JavaScript, we use the '+' operator. When the first string already contains a trailing space, we can directly concatenate without adding an explicit space. However, if there's no space, we need to add one manually between the strings. Method 1: First String Has Trailing Space When the first string already ends with a space, simple concatenation is sufficient: function concatenateStrings(str1, str2) { return (str1 ...

Read More

Conditionally change object property with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

To conditionally change object properties in JavaScript, you can use the logical AND operator (&&) combined with the spread operator. This approach allows you to merge properties into an object only when a condition is true. How It Works The logical AND operator returns the second operand if the first is truthy, or false if the first is falsy. When spreading false into an object, it has no effect, making it perfect for conditional property assignment. Syntax let newObject = { ...originalObject, ...condition && { propertyName: value ...

Read More

Find the number of times a value of an object property occurs in an array with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 192 Views

When working with arrays of objects, you often need to count how many times a specific property value appears. JavaScript's reduce() method combined with Map provides an efficient solution for this task. Using reduce() with Map The reduce() method processes each array element to build a frequency count. We use a Map to store the counts because it maintains insertion order and provides efficient lookups. const subjectDetails = [ { subjectId: '101', subjectName: 'JavaScript' ...

Read More
Showing 16651–16660 of 61,297 articles
Advertisements