Articles on Trending Technologies

Technical articles with clear explanations and examples

What is the role of throw statement in JavaScript?

Jennifer Nicholas
Jennifer Nicholas
Updated on 15-Mar-2026 241 Views

The throw statement in JavaScript is used to manually create and raise exceptions. When executed, it stops the normal execution flow and passes control to the nearest catch block. Syntax throw expression; The expression can be any value: string, number, boolean, object, or Error instance. Basic Example Here's how to use throw with a simple string message: function checkDivision() { var a = 100; ...

Read More

Apple Touch icon for websites in HTML

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 2K+ Views

Apple Touch Icons are custom icons that appear when users add your website to their iPhone or iPad home screen. These icons replace the default website screenshot with a professional-looking app-style icon. Basic Apple Touch Icon To add a basic Apple Touch Icon, include this in your HTML section: This creates a bookmark icon when users tap the share button and select "Add to Home Screen" on iOS devices. Multiple Sizes for Different Devices Different Apple devices require different icon sizes. Use the sizes attribute to specify multiple icons: ...

Read More

Comparison of CSS versions

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

Cascading Style Sheets (CSS) has evolved significantly since its inception. Understanding the differences between CSS versions helps developers choose the right features for their projects and maintain browser compatibility. CSS1 (1996) CSS1 became a W3C recommendation in December 1996. This initial version introduced the fundamental CSS language and a basic visual formatting model for HTML elements. It provided essential styling capabilities like fonts, colors, margins, and borders. CSS2 (1998) CSS2 became a W3C recommendation in May 1998, building upon CSS1 with significant enhancements: Media-specific style sheets for printers and aural devices Downloadable fonts support ...

Read More

How to add an active class to the current element with JavaScript?

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

Adding an active class to the current element allows you to highlight the selected item in navigation menus, tabs, or button groups. This technique uses JavaScript event listeners to dynamically manage CSS classes. Complete Example .btn { border: none; outline: none; padding: 10px 16px; background-color: #6ea2f0; cursor: pointer; color: white; ...

Read More

Sort the numbers so that the even numbers are ahead JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 266 Views

We have an array of numbers that contains some positive and negative even and odd numbers. We need to sort the array in ascending order but with a special requirement: all even numbers should appear before any odd number, and both groups should be sorted internally in ascending order. For example, if we have an array like [-2, 3, 6, -12, 9, 2, -4, -11, -8], the result should be [-12, -8, -4, -2, 2, 6, -11, 3, 9]. How It Works The solution uses a custom comparator function that: Checks if numbers are even ...

Read More

How to create a custom function similar to find() method in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 469 Views

Let's say we have the following records of studentId and studentName and want to check a specific student name: const studentDetails = [ { studentId: 101, studentName: "John" }, { studentId: 102, studentName: "David" }, { studentId: 103, ...

Read More

Function that parses number embedded in strings - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 184 Views

JavaScript's built-in functions like parseInt() and parseFloat() only parse numbers from the beginning of a string, stopping when they encounter non-numeric characters. When you need to extract all digits from anywhere within a string, you need a custom solution. The Problem with Built-in Methods Standard parsing methods fail with embedded numbers: console.log(parseInt('454ffdg54hg53')); // 454 (stops at first non-digit) console.log(parseFloat('12.34abc56.78')); // 12.34 (stops at 'a') 454 12.34 Method 1: Loop Through Characters This approach iterates through each character, extracting only digits: const numStr = '454ffdg54hg53'; ...

Read More

Capitalize letter in a string in order and create an array to store - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 160 Views

We are required to write a JavaScript function that takes in a string and turns it into a Mexican Wave i.e. resembling string produced by successive capital letters in every word. For example, if the string is: const str = 'edabit'; Then the output should be the following with successive single capital letters: const output = ["Edabit", "eDabit", "edAbit", "edaBit", "edabIt", "edabiT"]; Method 1: Using String Prototype Extension This approach extends the String prototype with a custom replaceAt method: const str = 'edabit'; const replaceAt = function(index, ...

Read More

How can I write a script to use either W3C DOM or IE 4 DOM depending on their availability?

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

If you want to write a script with the flexibility to use either W3C DOM or IE 4 DOM depending on their availability, then you can use a capability-testing approach that first checks for the existence of a method or property to determine whether the browser has the capability you desire. Capability Testing Approach The key is to test for specific DOM methods rather than browser names. This ensures your code works regardless of which browser implements which DOM standard. if (document.getElementById) { // If the W3C method exists, use it } else ...

Read More

How to set the style of the right border with JavaScript?

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

In this tutorial, we will learn to set a style of the right border with JavaScript. To set the style of the right border in JavaScript, use the borderRightStyle property. Set the style of the right border using this property. We can apply borders to an element from any side or all sides. We can customize that border on any side. Every edge of a border has a specific property that can use only for that edge. We can provide three parameters like style, color, and width for creating a border. CSS is used to do such tasks. But, ...

Read More
Showing 18391–18400 of 61,297 articles
Advertisements