top of page
  • Writer's pictureanniedanniels0

JavaScript String Methods


The String object in the JavaScript lets the user work with a series of characters, and it basically wraps the Javascript's string primitive data type with several helper methods.


As this section of the script automatically converts between string primitives and String objects, the user can call any of the helper methods that are of this object on a string primitive.

Here is the syntax for creating the object that has been depicted below:


var val = new String(string);


Please note that the String parameter is only a series of characters that are basically has been properly encoded.


There are generally two ways by which these objects can be created in this web development language:


• By string literal: This is generally created with the use of double-quotes.

• By string object (using the new keyword): This is basically created with the help of a new keyword.

Methods

There are several methods in the JavaScript String that is being used. Some of them are depicted below with a brief description:


Methods - Description


charAt() This method generally delivers the char value present at the specified index.


charCodeAt() This method generally delivers the Unicode value of a character present at the specified index.


concat() This method generally delivers a combination of two or more sets of characters.


indexOf() This method generally delivers the position of a char value present in the given set of characters.


lastIndexOf() This method generally delivers the position of a char value This method is basically present in the provided set of characters by searching a character from the last position.


search() This method is basically used to search a specified regular expression in a provided set of characters and returns its position if a match occurs.


match() It is generally used in order to search a specified regular expression in a provided set of characters and returns that regular expression in case a match occurs.

If you are an enthusiastic web development language and want to learn about this topic in detail the best option for you is to learn JavaScript Tutorial on the web for full details.


Read More........




23 views1 comment

Recent Posts

See All
bottom of page