Every Beginner JavaScript Developer Should be Known About This Methode

Hello Beginner JavaScript Developer lets we talk about some JS method it’s read properly and it will be benefited for you. Heppy Learning

  1. includes(): It is a case-sensitive search on the string if the string is found then return true otherwise return false

console.log([‘shakil’, ‘fariha’, ‘jannat’].indexOf(‘jannat’) >= 0); //true

2. replace(): replace a word in a sentence with some or all matches of a sentence

let result = “1 abc 2 abc 3”.replaceAll(“abc”, “xyz”);
// return “1 xyz 2 xyz 3”

3. subStr(): it returns portion string in a string it has 2 parameter 1st started index num 2nd where finisher index number

console.log ((‘abcdef’).substr( 1, 3)); // bcd

4. toLowerCase(): it is change all string in lower character

const str = ‘I am Good.’ ;

console.log(str.toLowerCase());
//output: “i am good.”

5. toUpperCase(): All character change to upper case

const str = ‘I am Good.’ ;
console.log(str.toLowerCase());
//output: “I AM GOOD.”

6. parseInt(): It is a converted string to a number

console.log(parseInt(‘10’)); // expected output: 10 (Number)

7. every(): It checks all array item in his function. it returns a boolean value

const isBig = (num) => num < 40;
const arr1 = [1, 30, 39, 29, 10, 13];
console.log(arr1.every(isBig));
// expected output: true

8. filter(): Search array item by argument and return a new array.

const name = [‘shakil’, ‘fariha’, ‘jannat’, ‘mitu’];
const result = name.filter(word => word.length > 5);
console.log(result);
// expected output: Array [“shakil”, “fariha”, “jannat”]

9. find(): It is Find item in array and return then item value..

const array1 = [5, 2, 8, 55, 44];
const found = array1.find(element => element > 10);
console.log(found);
// expected output: 55

10. forEach(): It is return each item in array list

const arr1 = [‘a’, ‘b’, ‘c’];
arr1.forEach(element => console.log(element));
// expected output: “a”
// expected output: “b”
// expected output: “c”

11. map(): The map() method creates a new array .map is a collection of elements where each element is stored as a Key, value pair.

const arr = [1, 4, 9, 16];
const map = arr.map(x => x + 2);
console.log(map);
// expected output: Array [3, 6, 11, 18]

Hello, I am Shakil Ahmed Front End Developer & I am also working as a MERN developer I Love ❤️ JS.