0% found this document useful (0 votes)
65 views

String Properties of Java

The document summarizes string properties and methods in JavaScript. It lists the length property, which returns the number of characters in a string. It also lists the prototype property, which allows adding properties and methods to any object. The document then lists several common string methods like charAt(), charCodeAt(), concat(), indexOf(), lastIndexOf(), localeCompare(), replace(), search(), slice(), and split(). It provides the syntax for each method and a brief description of its functionality.

Uploaded by

Iqra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

String Properties of Java

The document summarizes string properties and methods in JavaScript. It lists the length property, which returns the number of characters in a string. It also lists the prototype property, which allows adding properties and methods to any object. The document then lists several common string methods like charAt(), charCodeAt(), concat(), indexOf(), lastIndexOf(), localeCompare(), replace(), search(), slice(), and split(). It provides the syntax for each method and a brief description of its functionality.

Uploaded by

Iqra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

String Properties:

Property: Syntax:
Length: This property returns the
number of characters in a string.
string.length
Prototype: The prototype property allows
you to add properties and methods to any object.prototype.name = value
object (Number, Boolean, String, Date, etc.).

String Methods:

Method: Syntax:
charAt():charAt() is a method that returns the string.charAt(index)
character from the specified index.

charCodeAt ():This method returns a number


indicating the Unicode value of the character at
string.charCodeAt(index)
the given index.
concat ():This method adds two or more string.concat(string2, string3[, ...,
strings and returns a new single string.
stringN]);
indexOf (): This method returns the index
within the calling String object of the first
string.indexOf(searchValue[,
occurrence of the specified value, starting the
search at fromIndex or -1 if the value is not fromIndex])
found.
lastIndexOf (): This method returns the string.lastIndexOf(searchValue[,
index within the calling String object of the last
fromIndex])
occurrence of the specified value, starting the
search at fromIndex or -1 if the value is nfound.
localeCompare ():This method returns a
number indicating whether a reference string
comes before or after or is the same as the string.localeCompare( param )
given string in sorted order.
replace () :This method finds a match between a string.replace(regexp/substr,
regular expression and a string, and replaces the
matched substring with a new substring. newSubStr/function[, flags]);
Search ():This method executes the search for a
match between a regular expression and this String
object.. string.search(regexp);
slice ():This method extracts a section of a string.slice( beginslice [,
string and returns a new string. endSlice] );
split (): This method splits a String object
into an array of strings by separating the string
into substrings.
string.split([separator][, limit]);
This method returns the characters in a string
beginning at the specified location through the
specified number of characters.

You might also like