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
The set border that looks as though it is carved into the page
The CSS border-style property with the groove value creates a border that appears carved into the page, giving it a 3D inset effect. This style is useful for creating visual depth and making elements appear recessed. Syntax border-style: groove; Example Groove Border Example This paragraph has no border style applied. ...
Read MoreHow to convert a string in to a function in JavaScript?
To convert a string into a function in JavaScript, the eval() method can be used. This method takes a string as a parameter and evaluates it as JavaScript code, which can include function definitions. Syntax eval(string); Example: Converting String to Function In the following example, a string contains a JSON object where the 'age' property holds a function as a string. Using eval(), we convert this string into an actual executable function. var string = '{"name":"Ram", "age":"function() {return 27;}", "city":"New jersey"}'; var fun ...
Read MoreHide div that contains specific text with JavaScript?
In JavaScript, you can hide div elements containing specific text by using getElementsByClassName() to select elements, then iterating through them and checking their content. When a match is found, set the element's display style to 'none'. Basic Approach The process involves three main steps: Get all div elements with a specific class Loop through each element and check its text content Hide matching elements by setting display: none Example: Hide Divs with Specific Text Hide ...
Read MoreJavaScript example to filter an array depending on multiple checkbox conditions.
Following is the code to filter an array depending on multiple checkbox conditions using JavaScript. This example demonstrates how to apply cumulative filters based on user checkbox selections. Example Array Filter with Multiple Checkboxes body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; ...
Read MoreAppend the current array with the squares of corresponding elements of the array in JavaScript
We have an array of Numbers like this: const arr = [12, 19, 5, 7, 9, 11, 21, 4]; We have to write a function that takes in such an array and returns a new array with all the items of the original array appended by the squares of corresponding elements of the array. For this sample array, the output should be: [12, 19, 5, 7, 9, 11, 21, 4, 144, 361, 25, 49, 81, 121, 441, 16] Method 1: Using reduce() The reduce() method can accumulate the original array ...
Read MoreSeparate a string with a special character sequence into a pair of substrings in JavaScript?
When you have a string containing a special character sequence that acts as a delimiter, you can separate it into substrings using JavaScript's split() method with regular expressions. Problem Statement Consider this string with a special character sequence: " John Smith " We need to split this string at the delimiter and get clean substrings without extra whitespace. Syntax var regex = /\s*\s*/g; var result = string.trim().split(regex); Example var fullName = " John Smith "; console.log("Original string: " + fullName); var regularExpression = ...
Read MoreFinding persistence of number in JavaScript
The additive persistence of a number is the count of times you must repeatedly sum its digits until you get a single digit. This is a common programming problem that demonstrates recursion and digit manipulation. Understanding Additive Persistence For any positive integer, we replace it with the sum of its digits repeatedly until we reach a single digit (0-9). The number of iterations required is the additive persistence. For example, with 1679583: 1679583 → 1+6+7+9+5+8+3 = 39 (Pass 1) 39 → 3+9 = 12 ...
Read MoreIs it a good practice to end switch with defaults in JavaScript?
In this tutorial, we will learn if it is a good practice to end switch with defaults in JavaScript. In JavaScript, we generally use the if or if-else statements if we need to check any conditions. Still, if we need to check multiple conditions for an expression, it becomes very complex and unorganized, so we use the switch statements for that situation. The switch statement compares the value of an expression to a series of case clauses, then executes statements after the first case clause that matches the value, and so on, until a break statement is met. ...
Read MoreHow to define the number of nodes in a node list with JavaScript HTML DOM?
In this tutorial, we are going to learn how can we find the number of nodes present in a node list in JavaScript. To perform the specific operation, we need to use the HTML DOM which helps us to work with the object model of the webpage. Now let us first understand what a node is and what is a node list in HTML. Everything in an HTML document including element, text, attribute as well as the whole document is a node. Every small element present in an HTML document is part of the navigation tree of an HTML ...
Read MoreCSS content: attr() on HTML5 progress doesn't work
The CSS content: attr() function doesn't work directly with HTML5 elements due to browser rendering limitations. Here's how to work around this issue. The Problem When you try to use content: attr() with progress elements, it fails because progress bars use special internal pseudo-elements that don't support generated content in the same way as regular elements. HTML Structure .progress-container { position: relative; ...
Read More