Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to set the painting area of the background with JavaScript?
In this tutorial, we will learn how to set the painting area of the background with JavaScript using the backgroundClip property. The background-clip CSS property defines how far a background (color or image) extends within an element. It specifies whether the background extends beneath the border-box, padding-box, or content-box of an element. Understanding background-clip Property The background-clip property accepts three main values: border-box - Background extends to the outer edge of the border (default) padding-box - Background extends to the outer edge of the padding content-box ...
Read MoreHow to set focus on a text input in a list with AngularJS and HTML5
To set focus on a text input in a list with AngularJS, you need to create a custom directive that observes a focus attribute and programmatically sets focus when the condition is met. Creating the Focus Directive First, create a custom directive that will handle the focus functionality: Focus state: {{cue.isNewest}} ...
Read MoreFont size adjust of an element with CSS
The font-size-adjust CSS property enables you to adjust the x-height to make fonts more legible when fallback fonts are used. It helps maintain consistent visual font sizes across different font families. Syntax font-size-adjust: none | number; Parameters none - Default value. No font size adjustment. number - A positive number that specifies the aspect ratio (x-height divided by font size). How It Works The property calculates: adjusted font size = specified font size × (font-size-adjust value ÷ aspect ratio of actual font) ...
Read MoreAdd sizes for Bootstrap Buttons
Bootstrap provides several CSS classes to control button sizes, from large buttons to block-level buttons that span the full width of their container. Button Size Classes Class Description .btn-lg ...
Read MoreNo. of ways to empty an array in JavaScript
JavaScript provides several methods to empty an array. Each method has different use cases and behaviors, especially when multiple references to the same array exist. Method 1: Setting to New Array This method creates a new empty array and assigns it to the variable. However, it doesn't affect other references to the original array. Setting to New Array let arr = [1, 2, 3, ...
Read MoreSolution to the clumsy factorial problem in JavaScript
Normally, the factorial of a positive integer n is the product of all positive integers less than or equal to n. For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1. We instead make a clumsy factorial: using the integers in decreasing order, we swap out the multiply operations for a fixed rotation of operations: multiply (*), divide (/), add (+) and subtract (-) in this order. For example, clumsy(10) = 10 * 9 / 8 + 7 - 6 * 5 / 4 + ...
Read MoreAdd two array keeping duplicates only once - JavaScript
When working with two arrays, you often need to merge them while keeping only unique values. This operation combines arrays and removes duplicates in a single step. const arr1 = [2, 4, 5, 3, 7, 8, 9]; const arr2 = [1, 4, 5, 2, 3, 7, 6]; We need to write a JavaScript function that takes two arrays and returns a new array with all duplicates removed (each element appears only once). Using Set with Spread Operator (Recommended) The most efficient approach uses ES6 Set to automatically remove duplicates: const arr1 = ...
Read MoreConverting array to object by splitting the properties - JavaScript
We have an array of string literals in which each element has a dash (-). The property key is present to the left of dash and its value to the right. A sample input array would look something like this: const arr = ["playerName-Kai Havertz", "age-21", "nationality-German", "position-CAM", "languages-German, English, Spanish", "club-Chelsea"]; We are required to write a function that splits these strings and form an object out of this array. Let's write the code. It will loop over the array splitting each string and feeding it into the new object. Using forEach Method ...
Read MoreHow to return a value from a JavaScript function?
To return a value from a JavaScript function, use the return statement. The return statement sends a value back to the code that called the function and immediately exits the function. Syntax function functionName() { // function body return value; } Example: Basic Return Statement function concatenate(name, age) { var val = name + age; ...
Read MoreFor Hosts Locale how to convert a string to lowercase letters in JavaScript?
To convert a string to lowercase letters in JavaScript, use the toLocaleLowerCase() method. This method converts characters to lowercase according to the host's locale, making it ideal for international applications. Syntax string.toLocaleLowerCase([locale]) Parameters locale (optional): A string specifying the locale to use for conversion. If omitted, the host environment's current locale is used. Basic Example Here's how to use toLocaleLowerCase() to convert a string to lowercase: var str ...
Read More