Articles on Trending Technologies

Technical articles with clear explanations and examples

Determining rightness of a triangle – JavaScript

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

We are required to write a JavaScript function that takes in three numbers say a, b and c representing the length of three sides of a triangle. The function should return true if those three sides represent a right-angle triangle, false otherwise. Right Angle Triangle A triangle is a right-angle triangle if one of the three angles in the triangle is 90 degrees. And one angle in the triangle is 90 degrees when the square of the longest side is equal to the sum of squares of the other two sides. This is known as the Pythagorean ...

Read More

How to display JavaScript variable value in alert box?

varma
varma
Updated on 15-Mar-2026 8K+ Views

To display JavaScript variable values in an alert box, you can pass variables directly to the alert() function. This is useful for debugging or showing information to users. Basic Syntax alert(variableName); alert("Text: " + variableName); alert(`Template: ${variableName}`); Example: Displaying Single Variable function showSingle() { var message = "Hello World!"; alert(message); } ...

Read More

Unicode Byte Order Mark (BOM) character in HTML5 document.

Samual Sam
Samual Sam
Updated on 15-Mar-2026 783 Views

A byte order mark (BOM) consists of the character code U+FEFF at the beginning of a data stream, where it can be used as a signature defining the byte order and encoding form, primarily of unmarked plaintext files. In HTML5 documents, the BOM can help browsers automatically detect the file's encoding. What is a BOM? Many Windows programs (including Windows Notepad) add the bytes 0xEF, 0xBB, 0xBF at the start of any document saved as UTF-8. This is the UTF-8 encoding of the Unicode byte order mark (BOM), and is commonly referred to as a UTF-8 BOM even ...

Read More

Usage of border-top-width property in CSS

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 83 Views

The border-top-width property in CSS controls the thickness of an element's top border. This property only takes effect when a border style is defined. Syntax border-top-width: value; Property Values Value Description Example thin Specifies a thin border (typically 1px) border-top-width: thin; medium Specifies a medium border (typically 3px) border-top-width: medium; thick Specifies a thick border (typically 5px) border-top-width: thick; length Defines width in px, em, rem, etc. border-top-width: 8px; Example: Basic Usage ...

Read More

What is the importance of _without() method in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 374 Views

The _.without() method is part of the Underscore.js library that creates a new array by excluding specified values from an original array. It performs case-sensitive matching and removes all occurrences of the specified values. Syntax _.without(array, *values) Parameters array - The source array to filter *values - One or more values to exclude from the array Return Value Returns a new array with the specified values removed, preserving the original array order. Example: Removing Numbers The following example removes multiple numeric values from an array: ...

Read More

How to get the first n values of an array in JavaScript?

Aman Kumar
Aman Kumar
Updated on 15-Mar-2026 1K+ Views

In JavaScript, getting the first n elements from an array is a common operation. There are several built-in methods to accomplish this efficiently. First n values means extracting elements from index 0 to index n-1. For example, if n=3, you get elements at positions 0, 1, and 2. Using the slice() Method (Recommended) The slice() method is the most common and efficient way to get the first n elements. It creates a new array without modifying the original. Syntax array.slice(0, n) Example 1: Basic Usage ...

Read More

How to get the pixel depth and color depth of a screen in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 632 Views

The JavaScript window object provides methods to get screen display information through the screen object. Two important properties are screen.colorDepth and screen.pixelDepth which return the color depth and pixel depth of the browser screen respectively. Color Depth The screen.colorDepth property returns the number of bits used to display one color on the screen. Modern computers typically use 24-bit or 32-bit hardware for color resolution, where: 24-bit color: Supports 16.7 million colors (True Color) 32-bit color: Includes an alpha channel for transparency Syntax screen.colorDepth Example ...

Read More

Object.keys().map() VS Array.map() in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 865 Views

In JavaScript, Object.keys().map() and Array.map() serve different purposes. Object.keys() extracts object keys as an array, then applies map(), while Array.map() directly transforms array elements. Understanding Object.keys() Object.keys() returns an array of an object's property names (keys). When chained with map(), it allows you to transform these keys. Object Keys Example let obj = { ...

Read More

Merge objects in array with similar key JavaScript

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

When working with arrays of objects in JavaScript, you might need to merge objects that share a common key. This is useful when consolidating data from multiple sources or restructuring existing data. Let's say we have the following array of objects where each object has an id and various heading properties: const arr = [ {id: 1, h1: 'Daily tests'}, {id: 2, h1: 'Details'}, {id: 1, h2: 'Daily classes'}, {id: 3, h2: 'Results'}, {id: 2, h3: 'Admissions'}, ...

Read More

Strictly increasing or decreasing array - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 503 Views

In Mathematics, a strictly increasing function is one where values always increase, while a strictly decreasing function has values that always decrease. In JavaScript, we can check if an array follows either pattern. We need to write a function that takes an array of numbers and returns true if it's either strictly increasing or strictly decreasing, otherwise returns false. Understanding the Logic The key insight is to check if consecutive elements maintain the same slope (all increasing or all decreasing). We use a helper function sameSlope that compares three consecutive numbers to ensure they follow the same ...

Read More
Showing 17421–17430 of 61,297 articles
Advertisements