Articles on Trending Technologies

Technical articles with clear explanations and examples

Set the font stretch of an element with CSS

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

The CSS font-stretch property controls the width of characters in a font, allowing you to make text narrower or wider. This property only works if the font family has condensed or expanded variants available. Syntax font-stretch: value; Possible Values The font-stretch property accepts the following values: normal - Default width ultra-condensed - Most narrow extra-condensed - Very narrow condensed - Narrow semi-condensed - Slightly narrow semi-expanded - Slightly wide expanded - Wide extra-expanded - Very wide ultra-expanded - Most wide wider - Relative to parent narrower - Relative to parent ...

Read More

JavaScript array: Find all elements that appear more than n times

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 450 Views

In JavaScript, you can find all elements that appear more than n times in an array using various approaches. This is useful for data analysis, finding duplicates, or filtering frequent items. Problem Overview Given an array of numbers or strings with repeated entries, we need to write a function that takes a positive integer n and returns all elements that appear more than or equal to n times. Using Map() for Frequency Counting The most efficient approach uses a Map to track element frequencies, then filters elements that meet our criteria: const arr = ...

Read More

Assigning function to variable in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 281 Views

In JavaScript, you can assign a function to a variable in several ways. This allows you to store functions for later use, pass them as arguments, or return them from other functions. Method 1: Function Expression The most common way is using a function expression, where you assign an anonymous function to a variable: Function Assignment // Assigning function to variable ...

Read More

How does JavaScript 'return' statement work?

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

In this article, we will learn how to work with a return statement in JavaScript. A specific value from the function is returned to the function caller using the return statement. Whenever the return statement is run, the function will stop. The code that follows the return statement won't be available, due to which it is the last statement in a function. Using the return statement, we may return object types, including functions, objects, arrays, and primitive values like Boolean, integer, and string. By using the return statement, we can also return many items. To return several values ...

Read More

What is the role of pageXOffset property in JavaScript?

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

The pageXOffset property returns the number of pixels the document has been scrolled horizontally from the left edge of the window. It's a read-only property of the window object used to track horizontal scroll position. Syntax let horizontalScroll = window.pageXOffset; Return Value Returns a number representing the horizontal scroll position in pixels. Returns 0 if the document hasn't been scrolled horizontally. Example: Basic Usage div { ...

Read More

How to set all the four border radius properties at once with JavaScript?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 235 Views

In JavaScript, you can set all four border-radius properties at once using the borderRadius property. This property allows you to apply rounded corners to an element by setting a single value or multiple values for different corners. Syntax The borderRadius property can accept different formats: element.style.borderRadius = "10px"; // All corners element.style.borderRadius = "10px 20px"; // top-left/bottom-right, top-right/bottom-left element.style.borderRadius = "10px 20px 30px"; // top-left, top-right/bottom-left, bottom-right element.style.borderRadius = "10px 20px 30px 40px"; // top-left, top-right, bottom-right, bottom-left Example: ...

Read More

Difference between div~div and div:not(:first-of-type)?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 189 Views

In CSS, both div~div and div:not(:first-of-type) can select the same elements in many cases, but they work differently and have different specificity values. Understanding the Selectors The div~div selector uses the general sibling combinator (~) to select any div that comes after another div at the same level. The div:not(:first-of-type) selector targets all div elements except the first one of its type within its parent. Example Structure ...

Read More

How to find the common elements between two or more arrays in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 10K+ Views

In JavaScript, finding common elements between two or more arrays is a frequent requirement in web development. Arrays are objects that store multiple values, and there are several efficient methods to identify shared elements across them. Using for Loop The traditional approach uses nested for loops to compare each element of one array with every element of another array. This method works by creating an empty array and pushing matching elements into it. Example 1 Here's how to find common elements between two numeric arrays: Common elements between ...

Read More

Difference between == and === operator in JavaScript

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 15-Mar-2026 9K+ Views

JavaScript is widely used to create interactive web pages. It has many frameworks such as React JS, Angular JS, Node JS, etc. Like any other programming language, JavaScript also provides operators like arithmetic, relational, comparison operators, etc. The equality operator, i.e., "==" is one such comparison operator that checks whether the LHS is equal to RHS or not. This operator is present in all other programming languages but it is somewhat different in JavaScript. This is due to the fact that JavaScript is a loosely typed language, whereas all other languages are strictly typed. As JS is loosely typed, it ...

Read More

Fat arrow functions in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 382 Views

Fat arrow functions, introduced in ES6, provide a shorter syntax for writing functions in JavaScript. They use the => operator instead of the function keyword. Syntax // Basic syntax (param1, param2, ...) => { } // Single parameter (parentheses optional) param => { } // No parameters () => { } // Single expression (return implicit) (a, b) => a + b Basic Example Fat Arrow Functions ...

Read More
Showing 18871–18880 of 61,297 articles
Advertisements