The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.
So,A Map object iterates its elements in insertion order — a for...of loop returns an array of [key, value] for each iteration.
map() function returns a map object(which is an iterator) of the results after applying the given function to each item of a given iterable (list, tuple etc.) ....fun : It is a function to which map passes each element of given iterable.
You can build collections of elements and include them in JSX using curly braces {}.and we loop through this array that we build using the JavaScript map() function.
1. we loop through the numbers array using the JavaScript map() function. We return a < li> element for each item. Finally, we assign the resulting array of elements to listItems:
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:
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.
in JavaScript, spread syntax refers to the use of an ellipsis of three dots (…) to expand an iterable object into the list of arguments.
The … spread operator is useful for many different routine tasks in JavaScript, including the following:
in this example, the spread operator can quickly combine two arrays, an operation known as array concatenation:
As noted in this example, the spread operator can add an item to an another array with a natural, easy-to-understand syntax:
When working with state, we typically want state to be in only 1 component. In other terms, we want the lowest number of components with state as possible. This means that in order to change state in a different component, we have to pass down our functions as props to the component that needs to change state. This way, we can have functions in our child components that are able to change state. This is very useful for cases where you have a child component that has an onClick function or an onChange function that needs to change state in order for the user to see the correct information on the screen.
The process of passing down functions as props can be very confusing. It happens during the render, where you call a new component. During that component call, you pass in your function as a prop.
Increment(): It takes a variable and increments (changes) its value, and also returns this value. The increment can be a positive or negative number.
The Increment() function changes the value of its first argument.
You can assign a ref to the child component and then call the function form parent like this example :
I want to know more about how i can use The … spread operator for many different routine tasks in JavaScript







