Articles on Trending Technologies

Technical articles with clear explanations and examples

How to disable browser's back button with JavaScript?

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

To disable the browser's back button, you can use JavaScript's history.forward() method to prevent users from navigating backward. This technique forces the browser to stay on the current page when the back button is clicked. Basic Approach The core idea is to push the current page forward in history whenever the user tries to go back: Disable Browser Back Button Main Page Next Page ...

Read More

What are the differences between Deferreds, Promises and Futures in javascript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 1K+ Views

In JavaScript asynchronous programming, the terms Deferred, Promise, and Future are often used interchangeably, but they have subtle differences in their origins and implementations. What is a Future? Future is an older term from other programming languages that represents the same concept as a JavaScript Promise. In modern JavaScript, "Future" and "Promise" refer to the same thing - a placeholder for a value that will be available later. What is a Promise? A Promise represents a value that is not yet known. It acts as a proxy for a value that may not be available when ...

Read More

How to convert array to object in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 449 Views

Converting arrays to objects is a common task in JavaScript. There are several approaches depending on your data structure and requirements. Method 1: Array of Arrays to Objects with Alphabetic Keys Let's convert a nested array structure into objects with keys as English alphabet letters: const data = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]; const dataArr = data.map(arr => { return arr.reduce((acc, cur, index) => ({ ...acc, [String.fromCharCode(97 + index)]: ...

Read More

Remove extra spaces in string JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 841 Views

To remove extra spaces from strings in JavaScript, you can use several methods depending on your needs. Here are the most common approaches. Remove All Spaces To remove all spaces from a string, use the replace() method with a regular expression: var sentence = "My name is John Smith "; console.log("Original string:"); console.log(sentence); var noSpaces = sentence.replace(/\s+/g, ''); console.log("After removing all spaces:"); console.log(noSpaces); Original string: My name is John Smith After removing all spaces: MynameisJohnSmith Remove Leading and Trailing Spaces Use trim() to remove spaces only from the ...

Read More

Finding roots of a quadratic equation – JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 604 Views

A quadratic equation has the form ax² + bx + c = 0, where a, b, and c are coefficients. To find the roots, we use the quadratic formula and check if the discriminant is non-negative for real roots. Quadratic Formula The quadratic formula is: x = (-b ± √(b² - 4ac)) / (2a) The discriminant (b² - 4ac) determines the nature of roots: If discriminant > 0: Two distinct real roots If discriminant = 0: One repeated real root If discriminant < 0: No real roots (complex roots) Example ...

Read More

How to get the first index of an occurrence of the specified value in a string in JavaScript?

Manikanth Mani
Manikanth Mani
Updated on 15-Mar-2026 1K+ Views

To get the first index of an occurrence of the specified value in a string, use the JavaScript indexOf() method. This method returns the position of the first occurrence of the specified substring, or -1 if not found. Syntax string.indexOf(searchValue, startPosition) Parameters searchValue: The substring to search for (required) startPosition: The index to start searching from (optional, default is 0) Return Value Returns the index of the first occurrence of the specified value, or -1 if the value is not found. Example You can try to run the following code ...

Read More

How to set the CSS property that the transition effect is for with JavaScript?

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

Use the transitionProperty property in JavaScript to set which CSS properties should have transition effects. This property controls exactly which CSS properties will animate when they change. Syntax element.style.transitionProperty = "property1, property2, ..."; element.style.transitionProperty = "all"; // All properties element.style.transitionProperty = "none"; // No transitions Example Here's a complete example showing how to set transition properties dynamically: #div1 { ...

Read More

Super keyword in JavaScript?

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

In this article, we are going to discuss about the super keyword in JavaScript with suitable examples. The super keyword is used in JavaScript classes to access properties and methods of a parent class from a child class. It's essential for implementing proper inheritance in object-oriented programming. When a child class and parent class have methods with the same names, the super keyword helps distinguish between them. The child class must extend the parent class using the extends keyword to use super. Syntax The syntax to represent the super keyword is: super(arguments); ...

Read More

JavaScript Basic Array Methods

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 882 Views

In this article, we will learn about different basic array methods in JavaScript. These methods allow you to manipulate, search, and transform arrays effectively. Adding and Removing Elements JavaScript provides several methods to add and remove elements from arrays: Method Description ...

Read More

Get filename from string path in JavaScript?

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

We need to write a function that takes in a string file path and returns the filename. Filename usually lives right at the very end of any path, although we can solve this problem using regex but there exists a simpler one-line solution to it using the string split() method of JavaScript and we will use the same here. Let's say our file path is − "/app/base/controllers/filename.js" Using split() Method Following is the code to get file name from string path − const filePath = "/app/base/controllers/filename.js"; const extractFilename = (path) => { ...

Read More
Showing 16781–16790 of 61,297 articles
Advertisements