Front End Technology Articles

Page 316 of 652

Manipulating objects in array of objects in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 4K+ Views

In JavaScript, manipulating objects within an array of objects is a common task. JavaScript provides several built-in array methods like map(), filter(), find(), and slice() to efficiently handle these operations. What is Object Manipulation in Arrays? Object manipulation in arrays involves three main operations: Updating - Modifying existing object properties Filtering - Selecting objects based on criteria Adding - Creating new objects or properties JavaScript provides methods like map(), filter(), find(), slice(), sort(), reduce(), and others to perform these manipulations efficiently. Original Array ...

Read More

Mapping an array to a new array with default values in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 1K+ Views

In JavaScript, mapping an array to a new array with default values is a common task when you need to transform data while ensuring missing or invalid values are replaced with fallback values. What is Array Mapping? Array mapping creates a new array by transforming each element of an existing array through a callback function. The original array remains unchanged, and the new array has the same length. const numbers = [1, 2, 3]; const doubled = numbers.map(x => x * 2); console.log(numbers); // Original unchanged console.log(doubled); // New transformed array ...

Read More

Maximum decreasing adjacent elements in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 268 Views

In JavaScript, finding the maximum number of decreasing adjacent elements means identifying the longest consecutive sequence where each element is smaller than the previous one. This is essentially finding the longest decreasing subarray. Understanding the Problem We need to find the maximum count of consecutive decreasing pairs in an array. For example, in array [5, 4, 3, 2, 1], we have 4 decreasing pairs: (5, 4), (4, 3), (3, 2), and (2, 1). Finding Decreasing Adjacent Elements 5 arr[0] ...

Read More

How to stop refreshing the page on submit in JavaScript?

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

In this tutorial, we will learn how to prevent forms from refreshing the page when submitted in JavaScript. By default, form submission causes a page refresh, but there are several methods to override this behavior. Using event.preventDefault() to Stop Page Refresh The event.preventDefault() method is the most common and recommended way to prevent the default form submission behavior. Syntax form.addEventListener('submit', function(event) { event.preventDefault(); // Your custom form handling code here }); Example In this example, we create a simple contact form that prevents page ...

Read More

Converting string to an array in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 48K+ Views

In JavaScript, converting strings to arrays is a common task when you need to split text into characters or words for processing. JavaScript provides several built-in methods to accomplish this conversion efficiently. This article explores four different methods to convert strings to arrays, each suitable for different use cases and requirements. Using the split() Method The split() method is the most versatile approach for string-to-array conversion. It splits a string into an array of substrings based on a specified separator and returns a new array without modifying the original string. The split() method accepts two optional ...

Read More

How to call a function that returns another function in JavaScript?

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

In JavaScript, calling a function that returns another function involves understanding higher-order functions and closures. When a function returns another function, you can either store the returned function in a variable or call it immediately using double parentheses. Basic Syntax There are two main ways to call a function that returns another function: // Method 1: Store in variable then call let returnedFunction = outerFunction(); returnedFunction(); // Method 2: Call immediately outerFunction()(); Simple Example let outerFunction = function() { ...

Read More

How to stop forEach() method in JavaScript?

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

In JavaScript, programmers can use the forEach() method to iterate through array elements. We can call a callback function, which we pass as a parameter of the forEach() method for every array element. Sometimes, we may need to stop the forEach() loop after executing the callback function for some elements. We can use the 'break' keyword with a normal loop to stop it: for(let i = 0; i < length; i++){ // code if(some condition){ break; } } However, we ...

Read More

How to sort strings in JavaScript?

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

Sorting strings is essential for organizing data alphabetically in JavaScript applications. Whether displaying user lists, organizing menu items, or processing API data, string sorting helps create better user experiences. JavaScript provides built-in methods for sorting, but understanding different approaches helps you choose the right solution for your needs. Using the sort() Method The sort() method is JavaScript's built-in array sorting solution. Unlike other languages that sort numbers by default, JavaScript converts all elements to strings and sorts them alphabetically. Syntax arrayOfStrings.sort(); Basic String Sorting ...

Read More

How to convert array of strings to array of numbers in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 30K+ Views

In JavaScript, there are different ways to convert an array of strings to an array of numbers. The most common approaches include using the built-in parseInt() method, the Number() constructor, and the unary + operator. Using the parseInt() Method The parseInt() method is a built-in function in JavaScript that takes a string as an argument and returns an integer. This method can be used with the map() method to convert an array of strings to an array of numbers. Syntax parseInt(string, radix); Parameters ...

Read More

Top must-know Features of JavaScript

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

In this tutorial, we will understand the special features of JavaScript that make it one of the most popular and versatile programming languages in the world. JavaScript is a dynamic programming language with flexible features and extensive library support. GitHub hosts millions of JavaScript projects, demonstrating its widespread adoption for both front-end and back-end development. Its simple syntax and browser compatibility make it accessible to developers with basic knowledge of HTML, CSS, and programming fundamentals. Core JavaScript Features Client-Side Scripting JavaScript executes directly in the browser, enabling interactive web pages without server round-trips. This allows for real-time ...

Read More
Showing 3151–3160 of 6,519 articles
« Prev 1 314 315 316 317 318 652 Next »
Advertisements