Articles on Trending Technologies

Technical articles with clear explanations and examples

Align the text of a paragraph with CSS

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 544 Views

To align and control the positioning of text within a paragraph, CSS provides several properties including text-align for horizontal alignment and text-indent for first-line indentation. Text Alignment Properties The main CSS properties for text alignment are: text-align - Controls horizontal alignment (left, right, center, justify) text-indent - Indents the first line of a paragraph Using text-align Property .left { text-align: left; } .center { text-align: center; } ...

Read More

How to decode an encoded string in JavaScript?

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

In JavaScript, string decoding refers to converting encoded strings back to their original form. While escape() and unescape() were historically used, modern JavaScript provides better alternatives like decodeURIComponent() and decodeURI(). Using unescape() (Deprecated) The unescape() method decodes strings encoded by the escape() method. It replaces hexadecimal escape sequences with their corresponding characters. Syntax unescape(string) Example // Special character encoded with escape function var str = escape("Tutorialspoint!!"); document.write("Encoded : " + str); document.write(""); ...

Read More

How to sort strings with accented characters using JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 471 Views

JavaScript's default string sorting doesn't handle accented characters properly. The localeCompare() method provides locale-aware string comparison that correctly sorts accented characters. The Problem with Default Sort Using the default sort() method on strings with accented characters produces incorrect results because it compares Unicode code points rather than the actual alphabetical order. Default Sort Problem Default Sort (Incorrect) ...

Read More

Calling asynchronous code from index.html page in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 334 Views

Calling asynchronous code when an HTML page loads requires using async/await with event handlers. This allows you to run asynchronous operations during page initialization. Using onload with Async Function The most straightforward approach is to use the onload attribute with an async function: Async Code on Page Load Async Page Loading Example async function ...

Read More

Simplest code for array intersection in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 228 Views

Array intersection finds common elements between two or more arrays. In JavaScript, the simplest approach uses filter() combined with includes(). Basic Example Let's find common elements between two arrays: var firstNamesArray = ["John", "David", "Bob", "Sam", "Carol"]; var secondNamesArray = ["Mike", "Carol", "Adam", "David"]; var intersectionOfArray = firstNamesArray.filter(v => secondNamesArray.includes(v)); console.log("Intersection of two arrays:"); console.log(intersectionOfArray); Intersection of two arrays: [ 'David', 'Carol' ] How It Works The filter() method creates a new array with elements that pass the test. For each element in ...

Read More

Count total punctuations in a string - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 761 Views

In JavaScript, you can count punctuation marks in a string by checking each character against a set of punctuation symbols. Common punctuation marks include periods, commas, semicolons, exclamation marks, question marks, and quotation marks. Common Punctuation Characters '!', ", ", "'", ";", '"', ".", "-", "?" Example Here's a JavaScript function that counts punctuation marks in a string: const str = "This, is a-sentence;.Is this a sentence?"; const countPunctuation = str => { const punct = "!, ';".?-"; let count = 0; ...

Read More

Finding the maximum in a nested array - JavaScript

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

Let's say, we have to write a simple function in JavaScript that takes in the following array of Numbers (nested to any level) − const arr = [ 15, 24, [ 29, 85, 56, [ 36, 14, 6, 98, 34, 52 ], 22 ], 87, 60 ]; and return the greatest number present in ...

Read More

How to get a number of days in a specified month using JavaScript?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 1K+ Views

To get the number of days in a specified month in JavaScript, you can use the Date constructor with a clever trick: create a date for the first day of the next month, then subtract one day to get the last day of the target month. The Date Constructor Trick The key insight is that new Date(year, month, 0) returns the last day of the previous month. Since JavaScript months are zero-indexed (0 = January, 1 = February, etc.), passing the actual month number gives us the last day of that month. Basic Implementation ...

Read More

How to layout table cells, rows, and columns with JavaScript?

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

In this tutorial, we will learn how to lay out table cells, rows, and columns with JavaScript. We can construct and edit DOM (Document Object Model) elements using JavaScript. There are two ways to add HTML components, such as tables, to an HTML document. The first is to include the HTML table tag directly into our HTML webpage, and the second is to create the full table within our JavaScript code. The second method is the most commonly used for building and adding tables to the DOM. The tr abbreviation refers to the table row. This reflects the ...

Read More

Using FFMPEG with HTML5 for online video hosting

Samual Sam
Samual Sam
Updated on 15-Mar-2026 1K+ Views

HTML5 introduced the native element, enabling browsers to play videos without plugins like Flash. FFMPEG is a powerful command-line tool that can convert videos into HTML5-compatible formats for seamless web streaming. HTML5 Video Formats Modern browsers support three main video formats: Format Codec Browser Support MP4 ...

Read More
Showing 18951–18960 of 61,297 articles
Advertisements