Articles on Trending Technologies

Technical articles with clear explanations and examples

How to create a weight converter with HTML and JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 468 Views

Creating a weight converter with HTML and JavaScript involves building a simple form that takes weight input in one unit and converts it to another unit in real-time. This tutorial demonstrates how to create a kilogram to gram converter. HTML Structure The HTML provides the basic structure with an input field for kilograms and a display area for the converted grams: body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } input, span{ ...

Read More

Function borrowing in JavaScript.

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 440 Views

Function borrowing in JavaScript allows objects to use methods from other objects without inheriting from them. This is achieved using call(), apply(), and bind() methods. Understanding Function Borrowing When an object doesn't have a particular method but needs to use it, it can "borrow" that method from another object. The borrowed method executes in the context of the borrowing object using the this keyword. Using call() Method The call() method invokes a function with a specific this context and individual arguments. Function Borrowing with call() ...

Read More

Transform nested array into normal array with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 334 Views

In JavaScript, nested arrays can be flattened into a single-level array using several methods. The most common approach is the flat() method, which removes one level of nesting by default. What is Array Flattening? Array flattening transforms a nested array structure into a single-dimensional array. For example, converting [[1, 2], [3, 4]] into [1, 2, 3, 4]. Using flat() Method The flat() method creates a new array with sub-array elements flattened into it. Here's how to flatten a nested array containing objects: const arrayObject = [ [ ...

Read More

Filtering out primes from an array - JavaScript

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

We are required to write a JavaScript function that takes in an array of numbers and returns a new filtered array that does not contain any prime number. Problem Statement Given an array of numbers, we need to filter out all prime numbers and return only the composite and non-prime numbers. const arr = [34, 56, 3, 56, 4, 343, 68, 56, 34, 87, 8, 45, 34]; Understanding Prime Numbers A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Numbers like 2, ...

Read More

How to count JavaScript array objects?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 26K+ Views

In this tutorial, we will learn to count JavaScript array objects. The array is the data structure containing the strings, numbers, objects, etc., in JavaScript. The object is the one kind of entity that contains properties and methods related to it. We can access the object's properties and invoke the object method using the object's references. Generally, To find the array length, we can use the array.length property and it returns the total number of elements that the array includes. But what if we need to count only object elements? Here, this tutorial has various approaches to counting ...

Read More

How to set the width of the outline around an element with JavaScript?

Swarali Sree
Swarali Sree
Updated on 15-Mar-2026 203 Views

To set the outline width, use the outlineWidth property. The outline appears outside the border and doesn't affect the element's layout. You can set it using pixel values, keywords, or other CSS units. Syntax element.style.outlineWidth = value; Parameters The outlineWidth property accepts the following values: Pixel values: "1px", "5px", "10px" Keywords: "thin", "medium", "thick" Other units: "1em", "2rem", "0.5cm" Example #box { width: 450px; ...

Read More

How to make the user login for an offline web app?

George John
George John
Updated on 15-Mar-2026 550 Views

Offline web apps require a different authentication approach since they can't always connect to servers. The key is implementing local authentication with data synchronization when online. How Offline Login Works When online, authenticate against the server and store user credentials locally. When offline, authenticate against the local storage instead of the remote server. User Login Online? Check Server Offline? Check Local Grant Access ...

Read More

Bootstrap Collapsible list group

George John
George John
Updated on 15-Mar-2026 5K+ Views

To create a collapsible list group in Bootstrap, combine the panel-collapse property with the list-group property. This creates an expandable section containing a list of items that can be toggled with a click. Basic Structure A collapsible list group consists of three main components: Panel container: Wraps the entire collapsible section Panel header: Contains the clickable trigger element Collapsible content: Houses the list group items Example The following example demonstrates a collapsible list group with programming languages. Click the "Info" header to expand or collapse the list: ...

Read More

Inserting a key into a tree in Javascript

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

In a Binary Search Tree (BST), inserting a new key follows a simple rule: smaller values go to the left subtree, and larger values go to the right subtree. The first insertion creates the root node, while subsequent insertions traverse the tree to find the correct position. How BST Insertion Works The insertion process starts at the root and compares the new value with each node. If the value is smaller, we move left; if larger, we move right. When we reach a null position (leaf node), we insert the new node there. Binary ...

Read More

Execute digits in even places in a JavaScript array?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 222 Views

In JavaScript, extracting elements from even positions in an array requires understanding that array indexing starts from 0. Elements at even positions are at indices 0, 2, 4, etc., while elements at odd positions are at indices 1, 3, 5, etc. To extract elements from even positions, we can use various methods like filter(), traditional loops, or specific iteration patterns. Understanding Array Positions JavaScript arrays are zero-indexed, meaning: Even positions: indices 0, 2, 4, 6... Odd positions: indices 1, 3, 5, 7... Using the filter() Method The filter() method creates a new array ...

Read More
Showing 18161–18170 of 61,297 articles
Advertisements