Articles on Trending Technologies

Technical articles with clear explanations and examples

Queue Data Structure in Javascript

Sai Teja Kotha
Sai Teja Kotha
Updated on 15-Mar-2026 814 Views

In this article, we are going to discuss the queue data structure in JavaScript. It is a linear data structure where the enqueue and dequeue of elements follow the FIFO (first in first out) principle. The queue is open at both ends - one end is used to insert data (enqueue) and the other is used to remove data (dequeue). We use two pointers: rear for insertion and front for removal. A real-world example of the queue can be a single-lane one-way road, where the vehicle that enters first, exits first. Other examples include printer job queues, task scheduling, ...

Read More

How to convert a string to JavaScript object?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 689 Views

In JavaScript, you can convert a JSON string to an object using the JSON.parse() method. This is commonly needed when working with API responses or stored data. Syntax JSON.parse(string) Basic Example String to Object Conversion Original JSON String: {"name":"Rohan", "sports":["Cricket", "Football"], "country":"India"} Converted Object Properties: Convert to Object ...

Read More

Create a polyfill to replace nth occurrence of a string JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 709 Views

A polyfill is a piece of code that provides functionality that isn't natively supported. In this tutorial, we'll create a polyfill to remove the nth occurrence of a substring from a string in JavaScript. Problem Statement We need to create a polyfill function removeStr() that extends the String prototype. The function should: subStr → the substring whose nth occurrence needs to be removed num → the occurrence number to remove (1st, 2nd, 3rd, etc.) Return the modified string if successful, or -1 if the nth occurrence doesn't exist ...

Read More

How to remove certain number elements from an array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 640 Views

We are required to write a function that takes in an array of numbers and a number, and it should remove all the occurrences of that number from the array in-place. Let's explore different approaches to accomplish this task effectively. Method 1: Using Recursion with splice() We can use recursion to remove elements by finding and splicing them one by one. The recursive function continues until no more occurrences are found. const numbers = [1, 2, 0, 3, 0, 4, 0, 5]; const removeElement = (arr, element) => { if(arr.indexOf(element) !== ...

Read More

How to Hide a div in JavaScript on Button Click?

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

To hide a div in JavaScript on button click we will be discussing three different approaches with example codes. We will hide the div upon clicking the button and similarly display the hidden div upon clicking the button. In this article we are having a div element. Our task is to hide the div on clicking the button using JavaScript. Approaches to Hide div on Button Click Here is a list of approaches to hide a div in JavaScript on button click which we will be discussing in this article with stepwise explanation and complete example codes. ...

Read More

Checking if two arrays can form a sequence - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 300 Views

We are required to write a JavaScript function that takes in two arrays of numbers. And the function should return true if the two arrays upon combining and shuffling can form a consecutive sequence, false otherwise. For example − If the arrays are − const arr1 = [4, 6, 2, 9, 3]; const arr2 = [1, 5, 8, 7]; Then the output should be true because when combined and sorted, they form: [1, 2, 3, 4, 5, 6, 7, 8, 9] which is a consecutive sequence. Example Following is the code − ...

Read More

What are the rules to be followed for Object Definitions in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 516 Views

In this tutorial, we will discuss the rules to follow for Object Definitions in JavaScript. JavaScript is an object-oriented scripting language. An object contains many properties. The property consists of a key and a value. The property is known as a method when this value is a function. Predefined objects are available in the browser. We can also define our objects. A real-life example of an object is a cup. The color, design, weight, and material are the main properties of a cup. The object name and the property name are case-sensitive. To define a property, we ...

Read More

Configuring any CDN to deliver only one file no matter what URL has been requested

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 302 Views

Content Delivery Networks (CDNs) are typically designed to serve static files based on specific URL paths. However, there are scenarios where you need a CDN to deliver the same file regardless of the requested URL - commonly used for Single Page Applications (SPAs) that rely on client-side routing. Why Serve One File for All URLs? Single Page Applications like React, Vue, or Angular apps use client-side routing. When users navigate to different URLs, the same index.html file should be served, and JavaScript handles the routing internally. Method 1: Using CloudFlare Page Rules CloudFlare allows you to ...

Read More

JS Geolocation but without prompting possible?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 629 Views

No, you cannot access geolocation data without prompting the user. This is a mandatory security feature designed to protect user privacy. Location Permission Allow example.com to access your location? Block Allow ...

Read More

Change the width of the bottom border with CSS

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 286 Views

The border-bottom-width CSS property controls the thickness of an element's bottom border. This property only works when a border style is defined, as borders are invisible by default. Syntax border-bottom-width: value; Common values include thin, medium, thick, or specific measurements like 1px, 5px, 0.5em. Example This is demo content with a 6px bottom border. ...

Read More
Showing 17521–17530 of 61,299 articles
Advertisements