This is my reading notes for Code Fellows.
1)What does .map() return?
A new array with each element being the result of the callback function.
2)If I want to loop through an array and display each value in JSX, how do I do that in React?
The .map() method is the most commonly used function to iterate over an array of data in JSX.
3)Each list item needs a unique __.
key
4)What is the purpose of a key?
keys() returns an array whose elements are strings corresponding to the enumerable properties found directly upon object .
1)What is the spread operator?
The spread operator is a new addition to the set of operators in JavaScript ES6. It takes in an iterable (e.g an array) and expands it into individual elements.
2) List 4 things that the spread operator can do.
Calling Functions without Apply
Combine Arrays
Copying Arrays
Convert arguments or NodeList to Array
3) Give an example of using the spread operator to combine two arrays.
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2]
4) Give an example of using the spread operator to add a new item to an array.
const fewFruit = ['🍏','🍊','🍌']
const fewMoreFruit = ['🍉', '🍍', ...fewFruit]
console.log(fewMoreFruit) // Array(5) [ "🍉", "🍍", "🍏", "🍊", "🍌" ]
1)In the video, what is the first step that the developer does to pass functions between components?
can be passed like a prop eg: using this.
2)In your own words, what does the increment function do?
This function is used to run through the obj. and update the count based on the name being passed in.
3)How can you pass a method from a parent component into a child component?
using props.
4)How does the child component invoke a method that was passed to it from a parent component?
though props