Some Regular JavaScript Methods for JS Developers...
Tags: math, array, string, number
Published: 2021-05-05 15:38:13

Use of extracting string method

1 slice(start, end) Method
![1Slice](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dza27pwrnimbji8uo05c.png)

The Slice method takes two parameters, the first one where the extract starts position, and the last one extract end position.  The Slice method is used when some specific string is extracted in a string. If a parameter is negative, the position is counted from the end of the string. If you do not use the second parameter, the result will slice out the rest of the string. Slice can accept negative indexes.

2.substring(start, end) Method
![3subStr](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/to11kdmmk98l2c01xzec.png)

substring() is the same to slice() Method. The difference between substring() cannot accept negative indexes. This method also has two parameters first one is extracted start positions and the last one is extracted end position.

3 substr(start, length) Method
![3subStr](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u10d5rg3xnrmnzmzhl26.png)

substr() is also the same as slice() But the difference is that the second parameter specifies the length of the extracted part. If you omit the last parameter, the result will slice out the rest of the string.



Use of number method

4 parseInt() Method
![4parseInt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8mpfhr3fbzjburcq5hsk.png)

The parseInt() method parses a string. This method returns a whole number. These method spaces are allowed. Only the first number is returned.

5 parseFloat() Method
![5parseFloat](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce6aa4ip7x6dm77ee4r2.png)

The parseFloat() method converts strings to numbers. If the number cannot be converted, NaN (Not a Number) is returned. This method is used in regular needs.


Use of Math method

6 Math.abs() Method
![6abs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kqvbxz1jtblpel7c1r9x.png)

The Math.abs() returns the absolute (positive) value of x . When you need a positive value from a negative number it is a helpful method for a developer.


7 Math.pow() Method
![7pow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9opgo4hwlgz05ymzner0.png)

Math.pow(x, y) returns the value of x to the power of y. This is a built-in method in Javascript Math. 


Use of array method

8 Pop() method
![8pop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/78hmweigod53uyj1mc8f.png)

Array in js plays an important role in development. Pop() is a built-in method of javascript. The pop() method removes the last element from an array. This is a method of the array.

9 Push() method
![9push](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/muxbe11dyc6f2o13l3zy.png)

Sometimes we need to add some items in an array, so what we do that time! The push() method adds a new element at the end to an array. This method returns the new array length.

10 shift() method 
![10shift](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ik836no1n0en7dh1hzf.png)

The shift() method removes the first array element and "shifts" all other elements to a lower index. This array method is similar to pop() but different from removing item position.