Back to React Notes
Topic #11

ES6 Array map()

Array.map() transforms every item of an array into a new one, and it is the standard way React turns data into lists of UI. You will write it every day.


The map() Method

The map() method creates a new array with the results of calling a function for every array element.

Example

const numbers = [1, 2, 3, 4];
const doubled = numbers.map(x => x * 2);

map() in React

The map() method is commonly used in React to render lists of elements:

Example

const fruitlist = ['apple', 'banana', 'cherry'];

function MyList() {
  return (
    <ul>
      {fruitlist.map(fruit =>
        <li key={fruit}>{fruit}</li>
      )}
    </ul>
  );
}

Note: When using map() in React to create list items, each item needs a unique key prop.


map() with Objects

You can also use map() with arrays of objects:

Example

const users = [
  { id: 1, name: 'John', age: 30 },
  { id: 2, name: 'Jane', age: 25 },
  { id: 3, name: 'Bob', age: 35 }
];

function UserList() {
  return (
    <ul>
      {users.map(user =>
        <li key={user.id}>
          {user.name} is {user.age} years old
        </li>
      )}
    </ul>
  );
}

map() Parameters

The map() method takes three parameters:

  • currentValue - The current element being processed
  • index - The index of the current element (optional)
  • array - The array that map was called upon (optional)

Example

const fruitlist = ['apple', 'banana', 'cherry'];

function App() {
  return (
    <ul>
      {fruitlist.map((fruit, index, array) => {
        return (
          <li key={fruit}>
            Name: {fruit}, Index: {index}, Array: {array}
          </li>
        );
      })}
    </ul>
  );
}

Note: The map() method always returns a new array. It does not modify the original array.

Want to go beyond the notes?

Join Coding Now Tech Institute's React course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

ES6 Array map() – FAQs

Quick answers about learning ES6 Array map() in React.

This free note from Coding Now Tech Institute explains ES6 Array map() in React — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every React topic on Coding Now Tech Institute, including ES6 Array map(), is 100% free with no signup required.
With focused practice, most students grasp ES6 Array map() in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now