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 reduce an array while merging one of its field as well in JavaScript
Consider, we have the following array of objects − const arr = [{ id: 121, hobby: 'cycling' }, { id: 125, hobby: 'jogging' }, { id: 129, hobby: 'reading' }, { id: 121, hobby: 'writing' }, { id: 121, hobby: 'playing football' }, { id: 125, hobby: 'cooking' }, { id: 129, hobby: 'horse riding' }]; ...
Read MoreComparing ascii scores of strings - JavaScript
ASCII is a 7-bit character encoding standard where every character has a unique decimal code. In JavaScript, we can use the charCodeAt() method to get the ASCII value of any character. This article demonstrates how to compare two strings by calculating their ASCII scores (the sum of ASCII values of all characters) and finding the difference between them. Understanding ASCII Values Each character has a specific ASCII decimal value: console.log('A'.charCodeAt(0)); // 65 console.log('a'.charCodeAt(0)); // 97 console.log(' '.charCodeAt(0)); // 32 (space) console.log('1'.charCodeAt(0)); // 49 65 97 32 49 ...
Read MoreCounting below / par elements from an array - JavaScript
We are required to write a function that counts how many elements in an array are below or at/above a given number. Following is our array of Numbers − const array = [54, 54, 65, 73, 43, 78, 54, 54, 76, 3, 23, 78]; For example, if the number is 60, there should be 7 elements below it − 54, 54, 43, 54, 54, 3, 23 and 5 elements at or above it − 65, 73, 78, 76, 78 Using Array.reduce() Method The reduce() method processes ...
Read MoreHow can I list all cookies on the current page with JavaScript?
In JavaScript, you can list all cookies on the current page using the document.cookie property. This property returns a string containing all cookies as semicolon-separated key-value pairs. Basic Cookie Retrieval The simplest way to get all cookies is to access document.cookie directly: // Set some sample cookies first document.cookie = "username=john; path=/"; document.cookie = "theme=dark; path=/"; ...
Read MoreFind the non-digit character with JavaScript Regular Expression
In this tutorial, we will learn to find non-digit characters using JavaScript regular expressions. The \D metacharacter matches any character that is not a digit (0-9), including letters, spaces, and special characters. RegExp is an object that specifies patterns used for search and replace operations on strings or input validation. RegExp was introduced in ES1 and is fully supported by all browsers. Syntax The syntax for matching non-digit characters is: new RegExp("\D") // Constructor syntax /\D/ // Literal syntax (recommended) ...
Read MoreHow to use JavaScript DOM to change the padding of a table?
In this tutorial, we learn to use JavaScript DOM to change the padding of a table. To change the padding of a table, use the DOM padding property. The HTML table is used to display relational data on the user screen. We can easily show related or dependent data to the user and user can easily understand and determine the characteristics of the data with help of table. But, while we are showing the relational data to the user in the form of table, we need to make sure that the table is well structured and looking good according ...
Read MoreHTML5 Cross Browser iframe post message - child to parent?
HTML5's postMessage API enables secure communication between an iframe and its parent window across different domains. This is essential for cross-origin iframe communication where traditional methods fail due to browser security policies. Parent Window Setup The parent window needs to set up an event listener to receive messages from the child iframe. Here's the cross-browser compatible approach: Parent Window Parent Window ...
Read MoreSet the font weight with CSS
The font-weight property controls how bold or light text appears. It accepts keyword values like normal and bold, or numeric values from 100 to 900. Syntax font-weight: normal | bold | bolder | lighter | 100-900; Font Weight Values Value Description Numeric Equivalent normal Regular text weight 400 bold Bold text weight 700 bolder Bolder than parent element Relative lighter Lighter than parent element Relative Example: Different Font Weights Font Weight Example ...
Read MoreAsynchronous Functions and the Node Event Loop in Javascript
Asynchronous functions allow programs to continue executing without waiting for time-consuming operations to complete. This non-blocking behavior is fundamental to JavaScript and Node.js, enabling better user experience and efficient resource utilization. When executing expensive operations like network requests or file I/O, asynchronous functions prevent the entire program from freezing. Instead of blocking execution, these operations run in the background while other code continues to execute. Understanding Asynchronous Execution In synchronous programming, each operation must complete before the next one begins. Asynchronous programming allows multiple operations to run concurrently, with callbacks or promises handling completion. console.log('One'); ...
Read MoreMap an integer from decimal base to hexadecimal with custom mapping JavaScript
Usually when we convert a decimal to hexadecimal (base 16) we use the set 0123456789ABCDEF to map the number. We are required to write a function that does exactly the same but provides user the freedom to use any scale rather than the one mentioned above. For example − The hexadecimal notation of the decimal 363 is 16B But if the user decides to use, say, a scale 'qwertyuiopasdfgh' instead of '0123456789ABCDEF', the number 363, then will be represented by wus That's what we are required to do. So, let's do this by ...
Read More