Most important things in javaScript for react framework
variable, Array, and Object are the most important things for a react developer.
Array: An array is a special variable, which can hold more than one value at a time. It is usually used in react for stored data. Example:
var animals = ['dog', 'cat', 'elephant'];
There are some operations in react that's are usually do in react.
- filter
- find
- forEach
- indexOf
- map
- pop
- push
- slice etc.
Filter: The filter method is usually used in react to find specific data.
var animals = ['dog', 'cat', 'elephant'];
const animal = animals.filter(animal => animal.length = 3);
console.log(animal);
//["dog", "cat"]
ForEach: This method is used in react to doing an operation for all elements of an array.
var animals = ['dog', 'cat', 'elephant'];
const animal = animals.forEach(element => console.log(element));
// dog
// cat
// elephant
IndexOf: It is used to find the quantity of a data length.
var animals = ['dog', 'cat', 'elephant'];
console.log(animals.indexOf(animals);
// 3
Map: The map method is used for creating a new data collection with the results of calling a provided function on every element in the calling array.
var animals = [7, 5, 6];
const mapAnimal = animals.map(animal => animal*2) ;
console.log(mapAnimal);
// [14, 10, 6]
pop: This method removes the last element from a data collection and returns that element.
var animals = ['dog', 'cat', 'elephant'];
animals.pop();
console.log(animals);
//['dog', 'cat'];
Push: This method adds one or more elements to the end of a data list.
var animals = ['dog', 'cat', 'elephant'];
animals.push('cows');
console.log(animals);
// ['dog', 'cat', 'elephant', 'cows']
It's not at all. There is also some method that is used in react.