Articles on Trending Technologies

Technical articles with clear explanations and examples

How to format a number with two decimals in JavaScript?

Kumar Ishan
Kumar Ishan
Updated on 15-Mar-2026 102K+ Views

This tutorial will teach us how to format a number with two decimals using JavaScript. Formatting a number means rounding the number up to a specified decimal place. In JavaScript, we can apply many methods to perform the formatting. Some of them are listed as follows − The toFixed() Method Math.round() Method Math.floor() Method Math.ceil() Method Using toFixed() Method (Recommended) The toFixed() method formats a number with a specific number of digits to the right of the decimal. It returns a string representation ...

Read More

How to set the padding of an element with JavaScript?

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

In this tutorial, we will look at the methods to set the padding of an element with JavaScript. Padding can be termed as the space between an element's content and its border, whereas margin adds space around the edge. The padding property in JavaScript allows you to control this internal spacing dynamically. Understanding CSS Padding Values Before diving into JavaScript implementation, let's understand how padding values work: padding: 10px; Sets 10px padding to all four sides (top, right, bottom, left) padding: 10px 20px; Sets 10px to top/bottom, 20px to ...

Read More

Does 'position: absolute' conflict with flexbox?

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

The position: absolute property can work with flexbox, but understanding their interaction is crucial for proper layout control. How Absolute Positioning Affects Flexbox When you apply position: absolute to a flex container, it removes the container from the normal document flow but maintains its flexbox properties for arranging child elements. Basic Example Here's how to combine absolute positioning with flexbox: .parent { display: flex; ...

Read More

Add or subtract space between the words of a sentence with CSS

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 472 Views

The word-spacing property is used to add or subtract space between the words of a sentence. Possible values are normal or a number specifying space. Syntax word-spacing: normal | length | initial | inherit; Parameters Value Description normal Default spacing between words length ...

Read More

img-rounded Bootstrap class

George John
George John
Updated on 15-Mar-2026 356 Views

Use the img-rounded Bootstrap class to style your image and give it rounded corners. This class applies CSS border-radius to create smooth, rounded edges on images. Syntax Example Bootstrap Images Styling Images with Bootstrap ...

Read More

How to convert a node list to an array in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 432 Views

A NodeList is returned by DOM methods like querySelectorAll() and getElementsByClassName(). While it's array-like, it doesn't have all array methods. Converting it to a true array gives you access to methods like map(), filter(), and forEach(). Using Array.from() (Recommended) The Array.from() method is the modern and most readable way to convert a NodeList to an array: Convert NodeList to Array body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; padding: ...

Read More

Check for Ugly number in JavaScript

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

In the decimal number system, ugly numbers are positive integers whose only prime factors are 2, 3, or 5. This means an ugly number can be expressed as 2i × 3j × 5k where i, j, and k are non-negative integers. For example, the integers 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 are all ugly numbers because they only contain the prime factors 2, 3, and 5. However, 7, 11, 13, 14 are not ugly numbers as they contain other prime factors. Algorithm To check if a number is ugly, we repeatedly divide it ...

Read More

Create global variable in jQuery outside document.ready function?

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

To create a global variable in jQuery that can be accessed outside the document.ready function, you need to declare the variable in the global scope (outside any function) within the tag. Key Concepts Global variables in JavaScript are accessible from anywhere in your code. When working with jQuery, you can initialize global variables inside document.ready and use them in other functions. Example Global Variable in jQuery ...

Read More

Update JavaScript object with another object, but only existing keys?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 987 Views

To update a JavaScript object with values from another object while only affecting existing keys, you can use hasOwnProperty() to check if a key exists in the source object before updating it. Example var markDetails1 = { 'marks1': 78, 'marks2': 65 }; var markDetails2 = { 'marks2': 89, 'marks3': 90 }; function updateJavaScriptObject(details1, details2) { const outputObject = {}; Object.keys(details1) .forEach(obj => outputObject[obj] ...

Read More

Transpose of a two-dimensional array - JavaScript

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

The transpose of a matrix (2-D array) is simply a flipped version of the original matrix. We can transpose a matrix by switching its rows with its columns. For example, if we have a 3×3 matrix where the first row is [1, 1, 1], after transposing, the first column becomes [1, 1, 1]. Understanding Matrix Transpose Let's visualize how transposition works with a simple example: Original Matrix: [1, 1, 1] [2, 2, 2] [3, 3, 3] Transposed Matrix: [1, 2, 3] [1, 2, 3] [1, 2, 3] Method 1: In-Place Transpose ...

Read More
Showing 18931–18940 of 61,297 articles
Advertisements