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 remove elements using the splice() method in JavaScript?
The splice() method is used to remove elements from an array by specifying the starting index and the number of elements to delete. It modifies the original array and returns an array of the removed elements. Syntax array.splice(startIndex, deleteCount) Parameters startIndex: The index at which to start removing elements deleteCount: The number of elements to remove Example: Remove Single Element Splice Method Example Remove Elements using ...
Read MoreKeyed collections in JavaScript
Keyed collections are data structures in JavaScript where elements are organized by keys rather than indices. The two main keyed collections are Map and Set objects, which maintain insertion order and provide efficient key-based operations. Map Collection A Map object holds key-value pairs and remembers the original insertion order of the keys. Unlike objects, Map keys can be of any type. Map Collection Example Map Collection Demo ...
Read MoreHow to get the product of two integers without using * JavaScript
We are required to write a function that takes in two numbers and returns their product, but without using the (*) operator. Method 1: Using Division Operator We know that multiplication and division are inverse operations, so if we divide a number by another number's inverse, it's the same as multiplying the two numbers. The mathematical concept: a × b = a ÷ (1 ÷ b) const a = 20, b = 45; const product = (a, b) => a / (1 / b); console.log(product(a, b)); 900 Method 2: Using ...
Read MoreHow to compare two arrays in JavaScript and make a new one of true and false? JavaScript
We have 2 arrays in JavaScript and we want to compare one with the other to see if the elements of master array exists in keys array, and then make one new array of the same length that of the master array but containing only true and false (being true for the values that exists in keys array and false the ones that don't). Let's say, if the two arrays are − const master = [3, 9, 11, 2, 20]; const keys = [1, 2, 3]; Then the final array should be − ...
Read MoreDisplay all the values of an array in p tag on a web page with JavaScript
In JavaScript, you can display array values as paragraph elements on a web page using several approaches. Here are the most common methods without requiring external libraries. Method 1: Using forEach() with createElement Display Array Values const arrayValues = [1000000001, "John", "Smith", 100, 200, 3000]; const container ...
Read MoreHow to print a triangle formed of '#' using JavaScript?
In this tutorial, we will learn to print a triangle formed of '#' using JavaScript. You need to use nested loops to print a triangle formed of '#' in JavaScript. The outer loop controls the number of rows, while the inner loop controls how many '#' symbols to print in each row. Nested loops are loops that contain another loop inside them. We'll explore two approaches using different types of loops in JavaScript: for loop while loop Using for Loop to Print a Triangle The for loop ...
Read MoreWrite a Regular Expression to remove all special characters from a JavaScript String?
To remove all special characters from a JavaScript string, you can use regular expressions with the replace() method. The most common approach is using the pattern /[^\w\s]/g which matches any character that is not a word character or whitespace. Syntax string.replace(/[^\w\s]/g, '') Regular Expression Breakdown The pattern /[^\w\s]/g works as follows: [^...] - Negated character class (matches anything NOT in the brackets) \w - Word characters (a-z, A-Z, 0-9, _) \s - Whitespace characters (spaces, tabs, newlines) g - Global flag (replace all occurrences) Example: Basic Special Character Removal ...
Read MoreHow to set the alignment between the items inside a flexible container when the items do not use all available space with JavaScript?
The alignContent property in JavaScript controls how flex lines are distributed within a flex container when there's extra space on the cross axis. This property only works when items wrap to multiple lines. Syntax element.style.alignContent = "value"; Available Values The alignContent property accepts these values: flex-start - Lines packed toward the start flex-end - Lines packed toward the end center - Lines packed toward the center space-between - Lines evenly distributed space-around - Lines with equal space around them stretch - Lines stretch to fill the container (default) Example ...
Read MoreConvert coordinates to a place name with HTML5
For this, use Google Maps API to perform reverse geocoding. Geocoding refers to translating a human-readable address into a location on a map. The process of doing the converse, translating a location on the map into a human-readable address, is known as reverse geocoding. Getting User Location with HTML5 First, we'll use HTML5 Geolocation API to get the user's current coordinates: function getUserLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, showError); } else { ...
Read MoreHow to display rupee symbol in HTML
The Indian rupee symbol (₹) can be displayed in HTML using several methods. Here are the most reliable approaches to ensure proper display across different browsers. Using HTML Entity Code The most straightforward method is using the HTML entity code for the rupee symbol: Rupee Symbol Example Price: ₹500 Amount: ₹1000 Price: ₹500 Amount: ₹1000 Using Font Awesome Icons Font Awesome provides a reliable cross-browser solution with the rupee icon: ...
Read More