JSFiddle - React, Tailwind, and code Playground
by Nibin George
JavaScript
// function is to enable the creation of a new array from an array like object.It can also take a second argument, which is a map function to be applied to each element:
Array.from('lorem'); // ['l', 'o', 'r', 'e', 'm']
Array.from([1, 2, 3], x => x * x); // [1, 4, 9]
//find lets you iterate through an array and get the first element back that causes the given callback function to return true
let numbers = [1, 2, 3];
let oddNumber = numbers.find(x => x % 2 == 1);
console.log(oddNumber); // 1
// instead of returning the element that matched, it returns the index of that element.
let people = ['giroud', 'pogba', 'lemar'];
let index = people.findIndex(x => x === 'pogba');
console.log(index); // 1
let user = {
name: "John",
age: 30
};
console.log(Object.keys(user))
console.log(Object.values(user))
console.log(Object.entries(user))