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
JavaScript Match between 2 arrays
When working with two arrays in JavaScript, you often need to match elements from one array with corresponding elements in another. This article demonstrates how to extract user IDs from an object array based on a names array, maintaining the order of the names array. Problem Statement We have two arrays: one containing user objects with names and UIDs, and another containing just names. Our goal is to create a function that returns UIDs in the same order as they appear in the names array. const data = [{ name: 'Kamlesh Kapasi', ...
Read MoreWhat is the difference between an acronym and abbr tags?
In HTML, both acronym and abbreviation tags are used to mark shortened forms of words or phrases, but they have key differences in support and usage. An acronym is a word formed by taking the first letters of each word in a phrase (like "NASA" from "National Aeronautics and Space Administration"). An abbreviation is any shortened form of a word or phrase (like "Mr." for "Mister"). The Acronym Tag (Deprecated) The tag was used in older HTML versions to mark acronyms specifically. However, it is deprecated in HTML5 and should not be used in modern web ...
Read MoreHow to manipulate JavaScript's Date object?
JavaScript's Date object provides powerful methods to manipulate dates and times. You can use getter methods to retrieve date components and setter methods to modify them. Understanding these methods is essential for effective date manipulation in JavaScript applications. Once a Date object is created, numerous methods allow you to operate on it. Most methods let you get and set the year, month, day, hour, minute, second, and millisecond fields using either local time or UTC (universal, or GMT) time. Common Date Methods Here are the key methods used with Date objects: Sr.No Methods ...
Read MoreHow to set the boldness of the font with JavaScript?
Use the fontWeight property in JavaScript to set the font boldness. This CSS property accepts values like "normal", "bold", "bolder", "lighter", or numeric values from 100 to 900. Syntax element.style.fontWeight = value; Parameters The fontWeight property accepts the following values: Value Description "normal" Default weight (equivalent to 400) "bold" Bold weight (equivalent to 700) "bolder" Bolder than parent element "lighter" Lighter than parent element 100-900 Numeric values (100 = thinnest, 900 = boldest) Example: Setting Font Weight with ...
Read MoreGeolocation HTML5 enableHighAccuracy True, False or What?
The enableHighAccuracy property in HTML5 Geolocation API controls whether the device should use high-precision GPS or faster network-based location services. Syntax navigator.geolocation.getCurrentPosition( successCallback, errorCallback, { enableHighAccuracy: true, // or false timeout: 10000, maximumAge: 0 } ); enableHighAccuracy: true When set to true, requests the most accurate position possible, typically using GPS: ...
Read MorePositioning HTML5 SVG in the center of screen
To center an SVG element horizontally on the screen, you can use CSS properties like margin and display. This technique works by making the SVG a block-level element and setting automatic left and right margins. CSS for Centering SVG Apply the following CSS to center your SVG element: #svgelem { margin-left: auto; margin-right: auto; display: block; } HTML SVG Element Here's the SVG element that we'll center using the above CSS: ...
Read MoreExplain the event flow process in Javascript
The JavaScript event flow process describes how events propagate through the DOM tree when an event occurs. This process involves three key phases: capturing, target, and bubbling. Event Flow Phases Event Capturing: The event starts from the document root and travels down to the target element. Event Target: The actual DOM element where the event occurred. Event Bubbling: The event travels back up from the target element to the document root. ...
Read MoreJavaScript Const
The JavaScript const declaration creates variables that cannot be reassigned to another value or redeclared later. It was introduced in ES2015 (ES6) and provides block scope like let but with immutable binding. Syntax const variableName = value; Basic const Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } Const Example Try ...
Read MoreThe new.target in JavaScript
The new.target is a metaproperty that allows us to determine at runtime whether a function or constructor was called using the new keyword or not. It returns undefined when called as a regular function and references the constructor when called with new. Basic Syntax function MyConstructor() { if (new.target) { // Called with 'new' } else { // Called as regular function } } Example: Detecting Constructor ...
Read MoreSort array of points by ascending distance from a given point JavaScript
Let's say, we have an array of objects with each object having exactly two properties, x and y that represent the coordinates of a point. We have to write a function that takes in this array and an object with x and y coordinates of a point and we have to sort the points (objects) in the array according to the distance from the given point (nearest to farthest). The Distance Formula It is a mathematical formula that states that the shortest distance between two points (x1, y1) and (x2, y2) in a two-dimensional plane is given by ...
Read More