Use of extracting string method
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
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
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
The parseInt() method parses a string. This method returns a whole number. These method spaces are allowed. Only the first number is returned.
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
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.
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
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.
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.
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.
Top comments (0)