Javascript Articles

Page 295 of 534

How to append an item into a JavaScript array?

Sravani S
Sravani S
Updated on 15-Mar-2026 304 Views

To append an item to a JavaScript array, you can use several methods. The most common approach is the push() method, which adds elements to the end of an array. Using push() Method The push() method adds one or more elements to the end of an array and returns the new length: var arr = ["marketing", "technical", "finance", "sales"]; arr.push("HR"); ...

Read More

Align the text of a document with CSS

varma
varma
Updated on 15-Mar-2026 112 Views

The text-align property in CSS is used to align the text content within an element. It accepts several values: left (default), right, center, and justify. Syntax text-align: left | right | center | justify; Values left: Aligns text to the left edge (default) right: Aligns text to the right edge center: Centers the text horizontally justify: Spreads text evenly across the width, aligning both left and right edges Example Here's how to use different text alignment values: ...

Read More

How to create a zero-filled JavaScript array?

Ramu Prasad
Ramu Prasad
Updated on 15-Mar-2026 204 Views

To create a zero-filled JavaScript array, you have several methods available. The most common approaches include using Array.fill(), Array.from(), or typed arrays like Uint8Array. Using Array.fill() Method The Array.fill() method is the most straightforward way to create a zero-filled array: // Create array of length 5 filled with zeros var zeroArray = new Array(5).fill(0); document.write("Zero-filled array: " ...

Read More

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

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 471 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

How to convert an array into JavaScript string?

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

An array is the most popular and adaptable data structure you might employ in your regular programming. Converting an array into a JavaScript String can be done using several predefined methods and techniques. Using the toString() Method Using the join() Method Using JSON.stringify() Method Using Type Coercion Using the toString() Method The toString() method is a built-in JavaScript function that converts array elements into a comma-separated string. It's the simplest way to convert an array to string format. ...

Read More

How to add an element in the last of a JavaScript array?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 6K+ Views

In this tutorial, we will learn how to add an element to the last of a JavaScript array. The most common method to add an element to the end of the array is by using the Array push() method, but we will discuss multiple methods to achieve this. Using the Array.prototype.push() Method Using the Array.prototype.splice() Method Using Array Indexing Using the Array.prototype.push() Method To add an element at the end, use the JavaScript push() method. The push() method appends the given element(s) to the end of the array and ...

Read More

How to serialize a JavaScript array?

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 3K+ Views

In JavaScript, serializing an array means converting it into a string format that can be stored, transmitted, or reconstructed later. While jQuery's serializeArray() method is useful for form data, JavaScript provides native methods for general array serialization. What is Array Serialization? Array serialization converts a JavaScript array into a string representation. The most common approach uses JSON.stringify() to convert arrays into JSON strings, which can be easily transmitted to servers or stored in local storage. Using JSON.stringify() (Recommended) The JSON.stringify() method is the standard way to serialize JavaScript arrays: // Simple array serialization let ...

Read More

Underline text with CSS

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

Use the text-decoration property to underline text with CSS. This property provides several options for decorating text, with underline being one of the most commonly used values. Syntax text-decoration: underline; Basic Example India Different Underline Styles You can customize the underline appearance using additional properties: ...

Read More

How to extract the number of minutes from current time in JavaScript?

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

JavaScript uses timestamps based on Unix time (milliseconds since January 1, 1970 UTC) to handle dates and times. While humans understand time in hours and minutes, JavaScript provides built-in methods to extract specific time components from Date objects. In this tutorial, we will learn how to extract the number of minutes from the current time in JavaScript using the getMinutes() method. Date Object Methods The JavaScript Date object provides several methods to extract time components: getHours() − Returns the current hour (0-23) in 24-hour format getMinutes() − Returns the current minutes (0-59) getSeconds() − Returns ...

Read More

Strikethrough text with CSS

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

Use the text-decoration property to create strikethrough text with CSS. The line-through value draws a horizontal line through the middle of the text. Syntax text-decoration: line-through; Basic Example This text will be striked through. Using CSS Classes For better organization, use CSS classes instead of inline styles: ...

Read More
Showing 2941–2950 of 5,340 articles
« Prev 1 293 294 295 296 297 534 Next »
Advertisements