Today we will learn some javascript methods. These methods is handy but useful. if you are new in javascript that might be helpful for you. 

Array method

1. map()

map() method return new array. The returned array length same as original array. we can assume as a for loop but easier to implement than for loop. 

const array=[100, 50, 200];
const array2=array.map(element=>element*2)
console.log(array2)

//array2=[200, 100, 400]


2. filter()

it also returns array from an original array with meet a certain condition. 

const array=[100, 50, 200];
const array2=array.filter(element=>element>50)
console.log(array2)

//array2= [100, 200]

String Method
1. split()

split method use as a seperator. split method returns array.   its a string method that returns multiple substring array using a specified seperator. here we used comma operator 

const string="hello,ruhul,amin"
const array2=string.split("")
console.log(array2)
//array2=["hello", "ruhul", "amin"]

2. slice()

slice method extract string from an original string in a certain range. slice method returns string

 const string="hello,ruhul,amin"
const string2=string.slice(3,12)
console.log(string2)
// string2="lo,ruhul,"

3. indexOf() 

It finds and return the index of the first occurrence of an string. if string is not match  it returns -1 value. 

const string="hello,ruhul,amin"
const value=string.indexOf("z")
console.log(value)