Articles on Trending Technologies

Technical articles with clear explanations and examples

Convert nested array to string - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 597 Views

Converting a nested array to a string in JavaScript involves flattening all nested elements and concatenating their values. This is commonly needed when processing complex data structures. Problem Statement We need to write a JavaScript function that takes a nested array of literals and converts it to a single string by concatenating all values, regardless of nesting depth. const arr = [ 'hello', [ 'world', 'how', [ 'are', 'you', [ ...

Read More

Finding the difference between two arrays - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 615 Views

Finding the difference between two arrays means identifying elements that exist in one array but not in the other. This is a common operation when comparing datasets or finding unique values. We have two arrays of numbers like these: const arr1 = [12, 54, 2, 4, 6, 34, 3]; const arr2 = [54, 2, 5, 12, 4, 1, 3, 34]; We need to write a JavaScript function that takes in two such arrays and returns the elements that are not common to both arrays. Using indexOf() Method The traditional approach uses nested loops ...

Read More

How to set all the border left properties in one declaration with JavaScript?

Sai Subramanyam
Sai Subramanyam
Updated on 15-Mar-2026 156 Views

The borderLeft property in JavaScript allows you to set all the left border properties (width, style, and color) in a single declaration. This is more convenient than setting borderLeftWidth, borderLeftStyle, and borderLeftColor individually. Syntax element.style.borderLeft = "width style color"; Parameters width: Border thickness (e.g., "thin", "medium", "thick", or pixel values like "5px") style: Border style (e.g., "solid", "dashed", "dotted", "double") color: Border color (e.g., color names, hex codes, rgb values) Example ...

Read More

The correct way to work with HTML5 checkbox

Giri Raju
Giri Raju
Updated on 15-Mar-2026 268 Views

HTML5 checkboxes allow users to select multiple options from a list. The correct syntax uses the input element with type="checkbox". Syntax Basic Example Here's a simple checkbox form with labels: HTML5 Checkbox Example Mathematics ...

Read More

Increase or decrease the size of a font with CSS

Nikitha N
Nikitha N
Updated on 15-Mar-2026 724 Views

The font-size property in CSS controls the size of text elements. You can use various units and keywords to set font sizes, from absolute values like pixels to relative keywords like "small" and "large". Syntax font-size: value; Available Values The font-size property accepts several types of values: Absolute keywords: xx-small, x-small, small, medium, large, x-large, xx-large Relative keywords: smaller, larger Length units: pixels (px), points (pt), ems (em), rems (rem) Percentage: relative to parent element's font size Example: ...

Read More

Insert a specified element in a specified position in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 2K+ Views

In JavaScript, the insertAdjacentElement() method allows you to insert an existing DOM element at a specific position relative to another element. This method is useful for dynamically rearranging elements without removing them from the DOM first. Syntax element.insertAdjacentElement(position, elementToInsert); Parameters element - The target element where the new element will be positioned relative to position - A string specifying where to insert the element. Four possible values: 'beforebegin' - Before the target element 'afterbegin' - Inside the target element, as the first child 'beforeend' - Inside the target element, as the last ...

Read More

Differences between web-garden and a web-farm in Javascript

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 471 Views

In web application deployment, understanding the difference between Web Garden and Web Farm architectures is crucial for scaling JavaScript applications effectively. Both approaches handle increased traffic differently through process-based and server-based scaling respectively. What is a Web Garden? A Web Garden is a web hosting system that comprises multiple "processes" running on a single server. This means we have one physical machine executing multiple worker processes to handle incoming requests concurrently. Single Server (Web Garden) Process 1 ...

Read More

JavaScript Check for case insensitive values?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 323 Views

JavaScript provides several methods to check for case insensitive values. The most common approaches use toLowerCase(), toUpperCase(), or regular expressions. Using toLowerCase() Method Convert both values to lowercase before comparison: let name1 = "JOHN"; let name2 = "john"; console.log(name1.toLowerCase() === name2.toLowerCase()); // true console.log("Hello".toLowerCase() === "HELLO".toLowerCase()); // true true true Using Regular Expression Use the i flag for case insensitive matching: let allNames = ['john', 'John', 'JOHN']; let makeRegularExpression = new RegExp(allNames.join("|"), "i"); let hasValue = makeRegularExpression.test("JOHN"); console.log("Is Present=" + hasValue); // Direct regex approach let ...

Read More

Convert object to a Map - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

In JavaScript, you can convert an object to a Map using several approaches. Maps offer better performance for frequent additions and deletions compared to objects. Sample Object Let's start with this example object: const obj = { name: "Vikas", age: 45, occupation: "Frontend Developer", address: "Tilak Nagar, New Delhi", experience: 23, salary: "98000" }; Method 1: Using Object.entries() (Recommended) The most concise approach uses Object.entries() which returns key-value pairs ...

Read More

Merging boolean array with AND operator - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 830 Views

Let's say, we have an array of arrays of boolean like this − const arr = [[true, false, false], [false, false, false], [false, false, true]]; We are required to write a function that merges this array of arrays into a one-dimensional array by combining the corresponding elements of each subarray using the AND (&&) operator. Let's write the code for this function. We will be using Array.prototype.reduce() function to achieve this. Example Following is the code − const arr = [[true, false, false], [false, false, false], [false, false, true]]; const ...

Read More
Showing 18781–18790 of 61,297 articles
Advertisements