Most important things in javaScript for react framework

TAFSIR UDDIN
2 min readMay 6, 2021

--

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.

  1. filter
  2. find
  3. forEach
  4. indexOf
  5. map
  6. pop
  7. push
  8. 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.

--

--

TAFSIR UDDIN
TAFSIR UDDIN

Written by TAFSIR UDDIN

0 Followers

A struggling react developer.

No responses yet