Articles on Trending Technologies

Technical articles with clear explanations and examples

How to display output in javascript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 3K+ Views

JavaScript provides several methods to display output to users. Here are the four most common approaches for displaying data in web applications. Using innerHTML to Display in HTML Elements The innerHTML property allows you to insert content directly into HTML elements on your webpage. document.getElementById("demo").innerHTML = "Hello, World!"; Hello, World! Using document.write() Method The document.write() method writes content directly to the HTML document. ...

Read More

Javascript search for an object key in a set

Disha Verma
Disha Verma
Updated on 15-Mar-2026 514 Views

In JavaScript, to search for an object key in a Set, you need to understand how Sets store values and how objects behave in JavaScript. JavaScript Sets are useful objects that store unique values, making them excellent for handling distinct data. In this article, we'll explore different ways to search for an object key in a Set. JavaScript Set A Set in JavaScript is a collection of unique values. Values like numbers and strings can be compared directly, but objects are stored by reference. This means that even if two objects have the same properties, they are still ...

Read More

Inserting string at position x of another string using Javascript

Aman Kumar
Aman Kumar
Updated on 15-Mar-2026 1K+ Views

In this article, you are going to learn how to insert a string at a position in another string. JavaScript does not provide a direct method to insert a string at a specific position. However, we can achieve this using various string methods like slice(), substr(), and array methods like join(). Using the slice() Method The slice() method extracts a section of a string and returns a new string without modifying the original string. Syntax String.slice(start, end) Parameters start − Required. The position from where to start ...

Read More

JavaScript undefined Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 261 Views

The JavaScript undefined property represents a value that indicates a variable has been declared but not assigned a value, or a property that doesn't exist. What is undefined? undefined is a primitive value automatically assigned to variables that are declared but not initialized, and to object properties that don't exist. Common Cases Where undefined Occurs // Declared but not assigned let age; console.log(age); // undefined // Function with no return value function greet() { console.log("Hello"); } let result = greet(); console.log(result); // undefined // Accessing non-existent object property let ...

Read More

Can we modify built-in object prototypes in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 221 Views

Yes, JavaScript allows modifying built-in object prototypes, but it should be done carefully. You can extend native objects like String, Array, or global functions like alert(). What are Built-in Object Prototypes? Built-in object prototypes are the foundation objects that JavaScript provides, such as String.prototype, Array.prototype, and global functions like alert(). Modifying them affects all instances of that type. Example: Overriding the alert() Function Custom Alert Function ...

Read More

Top n max value from array of object JavaScript

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

Finding the top n objects with maximum values from an array is a common programming task. Let's explore how to get objects with the highest duration values from an array of objects. Problem Statement Given an array of objects, we need to create a function that returns the top n objects based on the highest duration values. const arr = [ {"id":0, "start":0, "duration":117, "slide":4, "view":0}, {"id":0, "start":0, "duration":12, "slide":1, "view":0}, {"id":0, "start":0, "duration":41, "slide":2, "view":0}, {"id":0, "start":0, "duration":29, "slide":3, ...

Read More

JavaScript Remove all '+' from array wherein every element is preceded by a + sign

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 220 Views

When working with arrays containing strings that start with a '+' sign, you can remove these characters using JavaScript's map() method combined with replace(). Problem Statement Let's say we have an array where every element is preceded by a '+' sign: var studentNames = [ '+John Smith', '+David Miller', '+Carol Taylor', '+John Doe', '+Adam Smith' ]; Using map() with replace() The map() method creates a new array by calling a function on each element. We use replace() to ...

Read More

Display resultant array based on the object's order determined by the first array in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 134 Views

When working with objects and arrays in JavaScript, you often need to reorder data based on a specific sequence. This article shows how to use an array to determine the order of values extracted from an object using the map() method. The Problem Consider an object containing key-value pairs and an array that defines the desired order. We want to create a new array with values from the object, ordered according to the array sequence. // Object with key-value pairs var lastName = { "John": "Smith", "David": "Miller", ...

Read More

Return index of first repeating character in a string - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 299 Views

We are required to write a JavaScript function that takes in a string and returns the index of first character that appears twice in the string. If there is no such character then we should return -1. Following is our string: const str = 'Hello world, how are you'; Example Following is the code: const str = 'Hello world, how are you'; const firstRepeating = str => { const map = new Map(); for(let i = 0; i < str.length; i++){ ...

Read More

How to convert a decimal number to roman using JavaScript?

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

Roman numerals are a number system that uses letters from the Latin alphabet to represent values. In this tutorial, you'll learn how to convert decimal numbers to Roman numerals using JavaScript. Roman Numeral Symbols Seven basic symbols form Roman numerals: I = 1 V = 5 X = 10 L = 50 C = 100 D = 500 M = 1000 Additionally, subtractive combinations are used for specific values: IV = 4 IX = 9 XL = 40 XC = 90 CD = 400 CM = 900 Algorithm The ...

Read More
Showing 17231–17240 of 61,297 articles
Advertisements