Uploaded by bbibesh8

react

advertisement
///////////////////////////////js concepts/////////////////////////////////////
== equality operator
=== strictly equality operator ..implicit conversion doest work difference in passing by value and address
a = 10;
b = a
now b = b+ 1 chages b to 11 and a to 10
but passing by reference like in case of array
a = [10,10]
b = a
this shows b = some memory adress that carries the value 10 , 10 and theres same memory adress for a and b now b .push(3) chages both a and b
...we need return for map() and not for foreach() because map is a higher order array method which iterates through provided list and calls function over each iteration and thus is stores the final result in a new list or array so to put the required values in that array we need return from functions ...whereas the foreach is just a normal for loop like looping techniques which helps to iterate over a list of data and perform the task and also it doesnt create
any new list or array for final answer so ..we dont need return for foreach map reduce and filter......................
map makes new array and returns that array of same length
filter ....arr.filter((a) => {
return a >5 }
this iterates through array and returns value greater than 5 doesnt change original array
reduce....reduce operates as said in function either sum or diff or ..and returns a value
///////////////////////////////js /////////////////////////////////////////////
......../////////..................react concepts...............///////////////////////////
props are to be passed and used they are read-only
each componenets are exported and imported
you cannot change the state directly the correct way is to use setText("..") fuction and change
...usestate you cannot update a variable like normally y do in js..ve to use usestate react hook . it returns an array with two element state variable:count and function to update the state variable : setcount and we can acess them using
arrayu destructuring.
/........previous state....
now heres the weird thing or y can call it a smart thing ...if y pass a function to an updater function of usestate ,...that function will automatically return
previous state as its argument
....destructuring let fruits = ["apple", "peach"]
let [fruit1, fruit3] = fruits;
fruit 1 = apple
and fruit 3 = peach by default ..this is destructuring
Download