Articles on Trending Technologies

Technical articles with clear explanations and examples

How can I find the index of a 2d array of objects in JavaScript?

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

To find the index of a specific object in a two-dimensional array, you need to search through both rows and columns. This involves using nested loops to traverse the matrix structure. Syntax function find2DIndex(matrix, searchCondition) { for (let row = 0; row < matrix.length; row++) { for (let col = 0; col < matrix[row].length; col++) { if (searchCondition(matrix[row][col])) { ...

Read More

Concatenating variable number of arrays into one - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 600 Views

We are required to write a JavaScript function that takes in any number of JavaScript arrays and returns one single array with all the values from input arrays concatenated into it. For example − If the input arrays are − [1, 5], [44, 67, 3], [2, 5], [7], [4], [3, 7], [6] Then the output should be − const output = [1, 5, 44, 67, 3, 2, 5, 7, 4, 3, 7, 6]; Using reduce() and concat() The most straightforward approach uses the reduce() method combined with concat() to merge ...

Read More

How and why does 'z'['toUpperCase']() in JavaScript work?

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

In JavaScript, the syntax 'z'['toUpperCase']() works because strings are objects, and you can access object methods using both dot notation and bracket notation. This alternative syntax calls the toUpperCase() method on the string 'z', converting it to uppercase. Syntax 'z'['toUpperCase']() // Returns 'Z' This is equivalent to the more common dot notation: 'z'.toUpperCase() // Returns 'Z' Why Does This Work? In JavaScript, there are two ways to access object properties and methods: Dot notation: object.property Bracket notation: object['property'] String literals like ...

Read More

HTML5 Input type=number removes leading zero

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 5K+ Views

HTML5's input type="number" automatically removes leading zeros because it treats the value as a numeric data type. This creates issues when you need to preserve leading zeros, such as for international phone numbers, postal codes, or ID numbers. The Problem When using type="number", browsers strip leading zeros from the input value: Show Value function showValue() { let input = document.getElementById('numberInput'); ...

Read More

HTML5 tag

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 307 Views

The HTML5 tag is used to create radial gradients in SVG graphics. It defines a smooth color transition that radiates from a center point outward in a circular pattern, making it perfect for creating lighting effects, shadows, and visual depth in SVG elements. Syntax Key Attributes cx, cy: Center point coordinates of the gradient (default: 50%) r: Radius of the gradient (default: 50%) fx, fy: Focal point coordinates for gradient focus gradientUnits: Coordinate system ("objectBoundingBox" or "userSpaceOnUse") Example: ...

Read More

Usage of border-right-color property in CSS

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 76 Views

The border-right-color property sets the color of an element's right border. It works independently of other border properties and allows you to customize just the right border color while leaving other borders unchanged. Syntax border-right-color: color | transparent | inherit; Values color - Any valid CSS color (hex, RGB, HSL, color names) transparent - Makes the border transparent inherit - Inherits the color from parent element Example: Basic Usage .demo { ...

Read More

How to add an element to a JavaScript object?

Vivek Verma
Vivek Verma
Updated on 15-Mar-2026 75K+ Views

In JavaScript, objects are real-time entities that contain properties and methods. Objects store data in key-value pairs, where keys are called properties and values are called property values. There are multiple ways to add new properties to existing JavaScript objects. Let's explore the most common approaches. Object Creation Syntax var obj = new Object(); Or using object literal syntax: var obj = {property1: value1, property2: value2}; Using Dot (.) Operator The dot operator is the most common way to add properties to JavaScript objects. It acts as a connector ...

Read More

Add a property to a JavaScript object constructor?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 953 Views

In this article, we'll go over how to add properties to a JavaScript object constructor with appropriate examples. Adding a property to an object constructor is different from adding a property to a normal object. Properties must be added inside the constructor function itself, not outside. This ensures all instances created from the constructor have access to these properties. To get a better understanding, let's look at the syntax and usage of constructors in JavaScript. Syntax The syntax for a constructor is: function Constructor() { // No parameters } ...

Read More

How to sort an HTML list using JavaScript?

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

Sorting an HTML list with JavaScript involves manipulating the DOM elements to reorder list items based on their content. Here are two effective approaches to accomplish this. Method 1: Using Array Methods (Recommended) This modern approach converts list items to an array, sorts them, and rebuilds the list: Sort HTML List Animal List Sorting Sort Alphabetically Zebra Elephant ...

Read More

When you should not use JavaScript Arrow Functions?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 234 Views

Arrow functions should not be used in certain scenarios because they don't have their own this binding. Instead, they inherit this from the enclosing lexical scope, which can lead to unexpected behavior. When NOT to Use Arrow Functions Object Methods Arrow functions should not be used as object methods because they don't bind this to the object. Instead, this refers to the global scope (window in browsers). Arrow Functions - Object Methods Arrow Function vs Regular Function in Objects ...

Read More
Showing 17131–17140 of 61,297 articles
Advertisements