HOME

JS Basic
JS HOME
JS Introduction
JS How To
JS Where To
JS Variables
JS Operators
JS Functions
JS Conditional
JS Looping
JS Guidelines

JS References
JS String Object
JS Array Object
JS Date Object
JS Math Object
JS Window Object
JS Frame Object
JS Form Object
JS Browser Object

Examples/Quiz
JS Examples
JS Quiz Test

Please visit our sponsors !

JavaScript String Object

previous next

The String object is used to work with text.


Examples

The length property
This example returns the number of characters in a string.

The fontcolor() method
This example returns a string in a specified color.

The indexOf() method
This example tests if a string contains a specified word and returns the position of where the word was found.

The match() method
This example tests if a string contains a specified word and returns the word if it was found.

The substr() and substring() methods
This example returns a specified part of a string.

The toLowerCase() and toUpperCase() methods
This example converts a string to lowercase and uppercase.


The String object

The String object is used to work with text.

The String object's properties and methods are described below:

NN: Netscape, IE: Internet Explorer, ECMA: Web Standard

Properties Explanation NN IE ECMA
length Returns the number of characters in a string 2.0 3.0 1.0

Methods Explanation NN IE ECMA
anchor() Returns a string as an anchor 2.0 3.0  
big() Returns a string in big text 2.0 3.0  
blink() Returns a string blinking 2.0    
bold() Returns a string in bold 2.0 3.0  
charAt() Returns the character at a specified position 2.0 3.0 1.0
charCodeAt() Returns the Unicode of the character at a specified position 4.0 4.0 1.0
concat() Returns two concatenated strings 4.0 4.0  
fixed() Returns a string as teletype 2.0 3.0  
fontcolor() Returns a string in a specified color 2.0 3.0  
fontsize() Returns a string in a specified size 2.0 3.0  
fromCharCode() Returns the character value of a Unicode 4.0 4.0  
indexOf() Returns the position of the first occurrence of a specified string inside another string. Returns -1 if it never occurs 2.0 3.0  
italics() Returns a string in italic 2.0 3.0  
lastIndexOf() Returns the position of the first occurrence of a specified string inside another string. Returns -1 if it never occurs. Note: This method starts from the right and moves left! 2.0 3.0  
link() Returns a string as a hyperlink 2.0 3.0  
match() Similar to indexOf and lastIndexOf, but this method returns the specified string, or "null", instead of a numeric value 4.0 4.0  
replace() Replaces some specified characters with some new specified characters 4.0 4.0  
search() Returns an integer if the string contains some specified characters, if not it returns -1 4.0 4.0  
slice() Returns a string containing a specified character index 4.0 4.0  
small() Returns a string as small text 2.0 3.0  
split() Splits a string into an array of strings 4.0 4.0 1.0
strike() Returns a string strikethrough 2.0 3.0  
sub() Returns a string as subscript 2.0 3.0  
substr() Returns the specified characters. 14,7 returns 7 characters, from the 14th character (starts at 0) 4.0 4.0  
substring() Returns the specified characters. 7,14 returns all characters from the 7th up to but not including the 14th (starts at 0) 2.0 3.0 1.0
sup() Returns a string as superscript 2.0 3.0  
toLowerCase() Converts a string to lower case 2.0 3.0 1.0
toUpperCase() Converts a string to upper case 2.0 3.0 1.0


previous next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

ASPHits
Active Server Pages Resource Web Site


Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search