String methods in JavaScript
String is one of the important data types in any programming language. String is used to hold any character or any value that is to be stored in text form. Examples: var name = "John".
In this article, we will see some of the useful methods of string in JavaScript which can be very useful in your day-to-day programming life as well as in JavaScript interviews.
charAt
charAt method is used to find the character at a given index inside a string. example, var name="John Doe"
Above code gives 'j' as an output.
endsWith
endsWith method gives a boolean value. It takes a string parameter and checks if the string ends with given parameter value.
Example