10 Methods Of JavaScript

So let’s get started.

……………………………………….

1. How to Split a String into an Array in JS

  • Split() method is used to split a string separately. String is split between each character. If you want to split a string with multiple separators then you have to pass regex expressions into a split method. That’s how we work with split method in JavaScript. The string.split() method does not change the original string.

2. String.toLowerCase() Method

string.toLowerCase() method is used to convert a string to lowercase letters. String toLowerCase() is a built-in JavaScript method that returns the calling string value converted to lowercase. The string.toLowerCase() method does not change the original string.

3. String.toUpperCase() Method

string.toUpperCase() method is used to convert a string to uppercase letters. String toUpperCase() is a built-in JavaScript method that returns the calling string value converted to uppercase. The string.toUpperCase() method does not change the original string.

4. string.replace() Method

string.replace() method is used to replace a part of the given string with some other string or a regular expression. string.replace() returns a new string where the specified values are replace. When we need to replace some letter or sentence, we simply use string.replace() method. The string.replace() method does not change the original string.

5. String.trim() Method

string.trim method is used to remove whitespace from both sides of a string. The trim() is a built-in string function in JavaScript. When we need to remove a whitespace from characters, we simply use string.trim() method. The trim() method does not change the original string.

6. String.trimStart() Method

string.trimStart method is used to remove whitespace from the beginning of a string. The trimStart() is a built-in string function in JavaScript. When we need to remove a whitespace from the beginning characters, we simply use string.trimStart() method. The trimStart() method does not change the original string.

7. String.trimEnd() Method

string.trimEnd method is used to remove whitespace from the end of a string. The trimEnd() is a built-in string function in JavaScript. When we need to remove a whitespace from the end characters, we simply use string.trimEnd() method. The trimEnd() method does not change the original string.

8. math.floor() Method

math.floor method is used to return the largest integer value that is less than or equal to a number. In other words, the floor() function rounds a number down and returns an integer value. The math.floor() is a built-in function in JavaScript. floor() is a static method of Math, you always use it as Math.floor().

9. array.push() Method

array.push() method is used to add items to the end of an array and returns the new length. . The array.push() is a built-in array function in JavaScript. When we need to add items to the end of an array we use array.push method. it is such a easy way to add items to the end of an array.

10. array.pop() Method

array.pop() method is used to remove items to the end of an array and decrements the length parameter. The array.pop() is a built-in array function in JavaScript. When we need to remove items to the end of an array we use array.pop method. It is such an easy way to remove items to the end of an array.