DEV Community

Cover image for Javascript Methods short discussion
Md Rasel
Md Rasel

Posted on

Javascript Methods short discussion

Array Methods

1.concat()

concat() is an array javascript method using for adding two or more arrays. It returns a new array for adding two or more arrays. You use concat method parameter in the second array name or using direct value. It is added the old/first array and returns a new array.

example:
Example Image

2.find()

find() is the javascript array method. it is using to search an array element in the array. The find method parameter you can provide a callback function then set your condition in the callback function. After the condition is true return this element otherwise return undefined.

example:
Example Image

3.findIndex()

findIndex method using for find array element index, you can provide a callback function in findIndex parameter then set the condition in callback function after matching the condition then return 1 otherwise return -1

example:
Example Image

4.filter()

filter method using for filter arrays. filter parameter must provide a callback function then set your condition in a callback function. Check the condition of all array elements. Then With those element conditions that have been true then return a new array for this element.

example:
Example Image

5.pop()

pop method using for the array the last element removed. If you use the pop method then remove the last element in your array and return this element.

example:
Example Image

6.shift()

shift method using for the array first element removed. If you use the shift method then remove the first element in your array and return this element.

example:
Example Image

7.push()

push method using to add a new element in the array and a new element is added to the last element in the array and return this array length.

example:
Example Image

8.unshift()

unshift method using to add a new element in the array and a new element is add the first element in the array and return this array length.

example:
Example Image

9.reverse()

reverse method is using for reverse array elements. If you use this method reverse all elements in your array and return this array.

example:
Example Image

10.join()

join method is using for converted all array elements to string. you use this method then return a string for all elements. You do not use any parameter in the join method parameter then add a comma by default in the middle for all elements and return this string, or you use an empty string then return only all elements.

example:
Example Image

String Methods

1.charAt()

charAt method is using for a letter in the string. You provide a parameter then return this index letter or by default return, the first index letter but your provided parameter is bigger than the array length then return an empty string.

example:
Example Image

2.concat()

concat() method used for adding two or more strings. It returns a new string for adding two or more strings. You use concat method parameter in the second variable name or using direct value. It is added the old/first string and returns a new string.

example:
Example Image

Math Methods

1.abs()

abs method is using for a negative number converted to a positive number and it is returning this converted number.

example:
Example Image

2.max()

The max method is using for two number difference and it is returning the maximum number.

example:
Example Image

3.min()

The min method is using for two number difference and it is returning the minimum number.

example:
Example Image

Top comments (0)