React Tutorial

React Home React Intro React Get Started React ES6 - ES6 Classes - ES6 Arrow Functions - ES6 Variables - ES6 Array Methods - ES6 Destucturing - ES6 Spread Operator - ES6 Modules - ES6 Ternary Operator React Render HTML React JSX React Components React Class React Props React Events React Conditionals React Lists React Forms React Router React Memo React CSS Styling

React Hooks

What is a Hook? useState useEffect useContext useRef useReducer useCallback useMemo Custom Hooks

React Redux

What is a Redux? React Redux Example

React Exercises

React Quiz

React ES6 Array Methods

In JavaScript, Arrays can be a collection of elements of any type. This means that you can create an array with elements of type String, Boolean, Number, Objects, and even other Arrays.

An Arrays is a data structure that contains list of elements which store multiple values in a single variable.

In javascript, There are many JavaScript array methods.

  • map( )
  • filter( )
  • sort( )
  • forEach( )
  • concat( )
  • every( )
  • some( )
  • includes( )
  • join( )
  • reduce( )
  • find( )
  • findIndex( )
  • indexOf( )
  • fill( )
  • slice( )
  • reverse( )
  • push( )
  • pop( )
  • shift( )
  • unshift( )

In React, the .map() array method is most useful.

map( ) method

This method creates a new array with the results of calling a provided function on every element in this array.

In React, map( ) can be used to generate lists of items.


import React from 'react';
import ReactDOM from 'react-dom';

const myArray = ['kiwi', 'pineapple', 'apple'];

const myList = myArray.map((item) => <p>{item}</p>)

ReactDOM.render(myList, document.getElementById('root'));

Output :