Articles on Trending Technologies

Technical articles with clear explanations and examples

How to combine multiple elements and append the result into a div using JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 8K+ Views

Sometimes, we require to manipulate the HTML elements using JavaScript. So, we can use JavaScript to add or remove HTML elements. This tutorial will teach us to combine multiple HTML elements in a single shot using JavaScript. Sometimes we need to show some HTML elements to users when they click the button or particular event triggers. So, we can use the approaches below to combine multiple elements and append the result into a div element using JavaScript. Use the innerHTML Property The innerHTML, as the name suggests, allows us to set the HTML for any particular element ...

Read More

How to transform a String into a function in JavaScript?

Mohit Panchasara
Mohit Panchasara
Updated on 15-Mar-2026 3K+ Views

We have given a string and need to convert it into a function in JavaScript. Sometimes, we get mathematical or function expressions in the form of the string, and executing that expression, requires converting strings into the function expression. In this tutorial, we will learn different approaches to converting the given string into a functional or mathematical expression. Use the eval() method The eval() method takes the expression as a parameter and evaluates the expression. For example, if we pass the '2 + 2' string as a parameter of the eval() method, it returns 4 as it evaluates ...

Read More

Check if a value exists in an array and get the next value JavaScript

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

We are required to write a JavaScript function that takes in an array of literals as the first argument and a search string as the second argument. The function should search the array for that search string. If that string exists in the array, we should return its next element from the array, otherwise we should return false. Example const arr = ["", "comp", "myval", "view", "1"]; const getNext = (value, arr) => { const a = [undefined].concat(arr); const p = a.indexOf(value) + 1; ...

Read More

Finding Mode in a Binary Search Tree in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 395 Views

Mode of a set of data is the number that occurs most frequently. For instance, 3 is the mode of dataset [2, 3, 1, 3, 4, 2, 3, 1] as it appears three times, more than any other number. Binary Search Tree A Binary Search Tree (BST) is a tree data structure where: The left subtree of a node contains only nodes with keys less than or equal to the node's key. The right subtree of a node contains only nodes with keys greater than or equal to the node's ...

Read More

Building a Text Editor using Quill.js

Mukul Latiyan
Mukul Latiyan
Updated on 15-Mar-2026 4K+ Views

Quill is a free and open-source WYSIWYG (What You See Is What You Get) text editor built for modern web applications. It offers a highly customizable interface with an expressive API, making it easy to integrate rich text editing capabilities into your projects. In this tutorial, we'll explore how to build text editors using Quill.js through practical examples, from basic setup to advanced customization. Setting Up Quill.js To get started with Quill, include the CSS and JavaScript files in your HTML document's section: The first link provides the CSS styling, ...

Read More

How to draw an octagon with Polygon object using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 419 Views

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. Syntax new fabric.Polygon( points: Array, options: Object ) Parameters points − This parameter accepts an Array which denotes the array of points that make up the polygon object. options (optional) − This parameter ...

Read More

Top JavaScript Best Practices and Standards to Know

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 292 Views

JavaScript is a powerful programming language widely used for building web applications. Following established best practices ensures your code is maintainable, readable, and performs efficiently. This guide covers essential JavaScript standards every developer should know. Code Organization and Naming Use clear, descriptive names that explain what variables and functions do. Good naming makes code self-documenting and easier to maintain. // Bad naming let d = new Date(); let u = users.filter(x => x.a > 18); // Good naming let currentDate = new Date(); let activeUsers = users.filter(user => user.age > 18); ...

Read More

Comparing adjacent element and swap - JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 478 Views

Bubble sort is a simple sorting algorithm that compares adjacent elements and swaps them if they are in the wrong order. This process repeats until the array is sorted. How Bubble Sort Works The algorithm repeatedly steps through the array, compares adjacent elements, and swaps them if they are in the wrong order. Each pass "bubbles" the largest element to its correct position. Bubble Sort Process Initial: 10 30 5 ...

Read More

Wrap object properties of type string with arrays - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 594 Views

When working with objects, you may need to ensure all properties are arrays. This is useful for normalizing data structures where some properties might be strings while others are already arrays. The Problem Consider an object where some properties are strings and others are arrays. To process them uniformly, you need all properties to be arrays: var details = { name: ["John", "David"], age1: "21", age2: "23" }; console.log("Original object:"); console.log(details); Original object: { name: [ ...

Read More

Longest distance between 1s in binary JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 467 Views

We are required to write a JavaScript function that takes a positive integer n and finds the longest distance between any two adjacent 1's in its binary representation. If there are no two adjacent 1's, the function returns 0. Two 1's are adjacent if there are only 0's separating them (possibly no 0's). The distance between two 1's is the absolute difference between their bit positions. Understanding the Problem For example, in the binary representation "1001", the two 1's have a distance of 3 (positions 0 and 3). Let's examine the number 22: ...

Read More
Showing 16621–16630 of 61,297 articles
Advertisements