- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
07-12-2022 01:09 AM - edited 10-11-2022 02:19 AM
ServiceNow JavaScript tutorials String functions | ServiceNow javascript Examples on string function
Hi All,
Hope you are doing fine.
In today's tutorial, we will be looking into various Javascript string functions which can be of great use in our day-to-day ServiceNow development activity.
In this ServiceNow javascript tutorial, we will try to look into various Javascript string functions along with the examples for the same.
What is String in JavaScript?
The JavaScript string is an object that represents a sequence of characters.
There are 2 ways to create strings in JavaScript
- By string literal
- By string object (using the new keyword)
The functions which will be explained in this tutorial are as given below :
charAt(): It provides the char value present at the specified index.
charCodeAt(): It provides the Unicode value of a character present at the specified index.
concat(): It provides a combination of two or more strings.
indexOf(): It provides the position of a char value present in the given string.
lastIndexOf(): It provides the position of a char value present in the given string by searching a character from the last position.
search(): It searches a specified regular expression in a given string and returns its position if a match occurs.
match(): It searches a specified regular expression in a given string and returns that regular expression if a match occurs.
replace(): It replaces a given string with the specified replacement.
substr(): It is used to fetch the part of the given string on the basis of the specified starting position and length.
substring(): It is used to fetch the part of the given string on the basis of the specified index.
slice(): It is used to fetch the part of the given string. It allows us to assign positive as a well negative index.
toLowerCase(): It converts the given string into the lowercase letter.
toLocaleLowerCase(): It converts the given string into a lowercase letter on the basis of the host's current locale.
toUpperCase(): It converts the given string into the uppercase letter.
toLocaleUpperCase() It converts the given string into an uppercase letter on the basis of the host's current locale.
toString(): It provides a string representing a particular object.
valueOf(): It provides the primitive value of a String object.
split(): It splits a string into a substring array, then returns that newly created array.
trim(): It trims the white space from the left and right sides of the string.
Hope you like this video.
Thanks and Regards,
Amit Gujarathi
- 8,640 Views