GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — JavaScript Array flatMap() Method - GeeksforGeeks JavaScript Array flatMap() MethodLast Updated : 11 Jul, 2025 The flatMap() method transforms each element of an array using a mapping function and flattens the result into a new array. It applies the function to every element, avoiding empty ones, and preserves the original array. Syntax:let A = array.flatMap(function callback(current_value, index, Array)) { Parameters:
Return Values:It returns a new array whose elements are the return value of the callback function. Example 1: In this example the flatMap() method doubles and squares each number in the array, creating a new flattened array, making complex transformations manageable.
Output [ 2, 1, 4, 4, 6, 9, 8, 16 ] Example 2: In this example, the
Output [ 'Hello', 'world', 'How', 'are', 'you?', 'JavaScript', 'is', 'fun' ] We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete reference article. Supported Browser:Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |