.

String objects in JavaScript Assignment Help

String objects in JavaScript

Strings are represented as sequence of characters.

Syntax for declaration:

char str_name[size];

Syntax for string object creation

var onject_nae=new String(string);

20.1 String object Methods

charAt()

Fetches the character from the string at the given index value.


String objects in JavaScript Assignment Help Through Online Tutoring and Guided Sessions at MyAssignmentHelp


concat()

Joins the given two strings and forms a new string.

indexOf()

Displays the index value of the first occurrence of given character

lastIndexOf()

Displays the index value of the last occurrence of given character

replace()

It finds the specified substring from the given string and replace the specified sub string into a new string

toLocaleLowerCase()

Each character of the string is altered to small letter (a, b..z) for the current browser.

toLocaleUpperCase()

Each character of the string is altered to capital letter (A,B,..Z) for the current browser.

toLowerCase()

Each character of the string is altered to small letter (a, b..z).

toUpperCase()

Each character of the string is altered to capital letter (A, B..Z).

slice()

Fetches a part of a string and returns a new string.

substr()

By specifying the starting position and the number of characters, the function retrieves the characters from a given string

substring()

By specifying the starting index value and the ending index value, the function retrieves the characters from a given string

localeCompare()

It compares two strings and returns value based on it.

Example program:

string objects img1
.