Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 15 of 80

How do I replace a character at a particular index in JavaScript?

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

JavaScript strings are immutable, meaning you can't directly replace a character at a specific index like in other languages. However, we can use several approaches to create a new string with the character replaced at the desired position. In this tutorial, we'll explore two effective methods to replace a character at a particular index in a JavaScript string. Replace Character by Converting String to Array Using String Slicing with substring() Replace Character by Converting String to Array This method converts the string to an array, modifies the character ...

Read More

How to set the spacing between words in a text in JavaScript?

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

In this article, we will learn how to set the spacing between words in a text using JavaScript. Word spacing is critical on websites because it improves the legibility and readability of the text displayed on the page. You can generate an aesthetically pleasing and easy-to-read typeface using proper word spacing. In JavaScript, we use the wordSpacing property to set the spacing between the words in a text displayed on a website. Using the Style wordSpacing Property This JavaScript DOM property is used to get and set the spacing between the words in a text. You ...

Read More

How to set the bottom position of a positioned element with JavaScript?

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

In this tutorial, we will learn how to set the bottom position of a positioned element with JavaScript. The position property sets how the element should be positioned in the DOM, and the top, bottom, left, and right properties set the final location of the positioned elements. In JavaScript, we have different ways to set the bottom position of a positioned element, and in this tutorial, we will learn two of them − Using the style.bottom Property Using the style.setProperty Method Using the style.bottom Property In ...

Read More

How to set the stack order of a positioned element in JavaScript?

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

In this tutorial, we shall learn to set the stack order of a positioned element in JavaScript. To set the stack order, we can use the style zIndex property. Let's first check what the stack order is. The stack order says the order in which the DOM elements are displayed. This is the element's position on the z-axis. Now, what is a positioned element? A positioned element has relative, absolute, fixed, or static positions. Why do we need to go for the stack order? Elements might overlap and look clumsy when positioned; therefore, we go for the ...

Read More

How to compare two numbers in JavaScript?

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

In this tutorial, we will learn to compare two numbers in JavaScript. Whether you're a competitive coder or application developer, you'll often need to compare numbers and perform operations based on the comparison results. Many programmers think we can only compare numbers using equality operators, but we can also use less than () operators for comprehensive comparisons. Using the Strict Equality Operator (===) JavaScript has two equality operators: loose equality (==) and strict equality (===). The strict equality operator compares both value and data type, making it more reliable for number comparisons. Syntax let ...

Read More

How to set the style of an element's border with JavaScript?

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

In this tutorial, we shall learn to set the style of an element's border with JavaScript. To set the style of an element's border, use the borderStyle property in JavaScript. Let us discuss the borderStyle property available in detail. Using the borderStyle Property With the borderStyle property, we can set or return the style of an element's border. Syntax Following is the syntax to use the borderStyle property to set the style of an element's border with JavaScript − object.style.borderStyle = style; This syntax allows us to set the required border ...

Read More

How to access properties of an array of objects in JavaScript?

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

In JavaScript, accessing properties of objects within an array is a common task. Whether you're working with a single object or an array of objects, there are several methods to retrieve property values effectively. JavaScript objects are collections of key-value pairs called properties. When you have an array containing multiple objects, you need specific techniques to access the properties of each object. Let's explore the main approaches. Using Dot Notation Dot notation is the most straightforward way to access object properties when the property name is known and is a valid JavaScript identifier. The syntax is object.propertyName. ...

Read More

How to Compare Two Arrays in JavaScript?

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

In JavaScript, comparing arrays with == or === operators doesn't work as expected because they compare object references, not actual array contents. This article explores multiple effective methods to properly compare two arrays in JavaScript. When we try to compare arrays directly, JavaScript compares memory references rather than the array elements themselves, which typically results in false even for identical arrays. Why Direct Comparison Fails const arr1 = [1, 2, 3]; ...

Read More

How to print content of JavaScript object?

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

In this tutorial, we will learn to print the content of a JavaScript object. Objects are similar to variables, but they can contain many values. Javascript object values are written as key: value pairs, and each pair is separated by commas. It is used to access data from databases or any other sources. Following are the ways to print the content of JavaScript objects − Using the JSON.stringify() Method Using Object.values() Using a for-in loop Using JSON.stringify() Method The JSON.stringify() method converts JavaScript objects ...

Read More

How to merge two arrays in JavaScript?

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

In this tutorial, we will learn how to merge two arrays in JavaScript. In JavaScript, we can merge two arrays using different approaches. Here are the three most common methods: Using the Array concat() method Using the spread operator Using loop iteration Using the Array concat() Method The Array concat() method merges two or more arrays and returns a new array. This is one of the most popular methods for merging arrays in JavaScript. The method operates on an array, takes another array as a ...

Read More
Showing 141–150 of 793 articles
« Prev 1 13 14 15 16 17 80 Next »
Advertisements