Lists and Keys
Given the code below, we use the map() function to take an array of numbers and double their values. We assign the new array returned by map() to the variable doubled and log it:
(const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map((number) => number * 2);
console.log(doubled);)
Rendering Multiple Components
You can build collections of elements and include them in JSX using curly braces {}.
Keys
Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity.
Spread Operator in JavaScript
The spread operator is a useful and quick syntax for adding items to arrays, combining arrays or objects, and spreading an array out into a functionβs arguments.
what it can do ?
- Copying an array
- Using Math functions
- Combining objects
- Adding an item to a list

exapmles for using spread operators in different things :
1- Compine two arrays (```const objectOne = {hello: βπ€ͺβ}
(const objectTwo = {world: "π»"}
const objectThree = {...objectOne, ...objectTwo, laugh: "π"}
console.log(objectThree) // Object { hello: "π€ͺ", world: "π»", laugh: "π" }
const objectFour = {...objectOne, ...objectTwo, laugh: () => {console.log("π".repeat(5))}}
objectFour.laugh() // πππππ)
2- Adding an item to a list
(const fewFruit = ['π','π','π']
const fewMoreFruit = ['π', 'π', ...fewFruit]
console.log(fewMoreFruit) // Array(5) [ "π", "π", "π", "π", "π" ])
3- Combining objects into one
(const objectOne = {hello: "π€ͺ"}
const objectTwo = {world: "π»"}
const objectThree = {...objectOne, ...objectTwo, laugh: "π"}
console.log(objectThree) // Object { hello: "π€ͺ", world: "π»", laugh: "π" }
const objectFour = {...objectOne, ...objectTwo, laugh: () => {console.log("π".repeat(5))}}
objectFour.laugh() // πππππ)
Passing function between components:
- creates a bunch of person objects
- creates a function that loops through the array of objects that is defined in the state.
What does the increment do ?
then number increases each time the user click on the item
How does the child component invoke a method that was passed to it from a parent component?
By Passing the key to the methodName.
.