Basic javascript string methods and properties you should know
Tags: react, javascript, node, programming
Published: 2020-12-24 08:15:10

**Strings** are one of the essential features found in programming. Simply they are pieces of text. I am sure that you will come across it in every programming language you might be using(if you didn't). In this article, let's look at basic javascript **string methods** you should know.

*Let's get started:* 

**1. String length**
`length` property is one of the properties you will probably use in strings. It returns the length of the string.

![Alt Length](https://dev-to-uploads.s3.amazonaws.com/i/rqs58uw5ox1x9o5hvj6n.png)

**2. Convert to Lowercase**
`toLowerCase` method returns the lowercase version of the string.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/480a4hn24c6i1nah9glt.png)

**3. Convert to Uppercase**
`toUpperCase` method returns the uppercase version of the string.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uh6eqeymv42xqcu6yexm.png)

**4. startsWith method**
`startsWith` method returns whether the string starts with the provided string.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k6cgbsi73cvgqokgncob.png)

**5. endsWith method**
`endsWith` method returns whether the string ends with the provided string.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/x5mut3mhaff56w1izplg.png)

**6. includes method**
`includes` method checks whether a string contains the specified string/characters.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xn3rui4ml2r53rvivuyz.png)

**7. charAt method**
`charAt` method Returns the character at the specified index (position).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1b51210lqpg7sd2w7pda.png)

**8. concat method**
`concat` method joins two or more strings and returns a new joined strings.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1j7ibfsnurli2oczxzl9.png)

**9. repeat method**
`repeat` method Returns a new string with a specified number of copies of an existing string.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qz8qow1da099a83j0nkf.png)

**10. slice method**
`slice` method extracts a part of a string and returns a new string.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/btqa6yb04xtai9vylwt1.png)

**11. replace method**
`replace` method searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vd2yvonzkeohb4647f6o.png)

**12. split method**
The `split` method is used to split a string into an array of substrings and return the new array. If an empty string is used as the separator, the string is split between each character.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6tnihgxbg0qb4kav1k8y.png)

**13. trim method**
`trim` method removes whitespaces from both ends of the string. It does not change the original string.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zxf9ia6lzb1ukhkdqsb4.png)

**14. substr method**
`substr` method gets a substring beginning at the specified location and having the specified length.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/aomqnn8ido7eunfouskw.png)

**15. substring method**
`substring` method extracts the characters from a string, between two specified indices, and returns the new substring. It does not include the **end** index.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6jlnmgre3zsa8lhtbhws.png)

These are some basic string methods you should know. I promise you will need them sometime.

Did you find it helpful? You can find me on [Twitter](https://twitter.com/AbizeraOreste). Have a nice day!😍😍