- Advanced Topics
- Dynamic Web Client Programming (DHTML)
- Runtime Document Manipulation
- Event Handlers
- Running Scripts at Page Load
- DHTML Examples
- Advanced Web Client Programming
- Standards and Best Practices
A string is a type of variable which stores a string (chain of characters).
 Basic UseTo make a new string, you can make a variable and give it a value of
var foo = new String();
var foo = "my string";
foo = "bar"; //foo = "bar" foo = "barblah"; //foo = "barblah" foo += "bar"; //foo = "barblahbar"
Due to the delimiters, it's not possible to directly place either the single or double quote within the string when it's used to start or end the string. In order to work around that limitation, you can either switch to the other type of delimiter for that case, or place a backslash before the quote to ensure that it appears within the string:
foo = 'The cat says, "Meow!"'; foo = "The cat says, \"Meow!\""; foo = "It's \"cold\" today."; foo = 'It\'s "cold" today.';
 Properties and methods of the String() objectAs with all objects, Strings have some methods and properties.
 replace(text, newtext)The replace() function returns a string with content replaced.
var foo = "microsoft rox"; var newString = foo.replace("rox", "sux") alert(foo); //microsoft rox alert(newString); //microsoft sux
 toUpperCase()This function returns the current string in upper case.
var foo = "Hello!"; alert(foo.toUpperCase()); // HELLO!
 toLowerCase()This function returns the current string in lower case.
var foo = "Hello!"; alert(foo.toLowerCase()); // hello!
 length()Returns the length as an integer.
var foo = "Hello!"; alert(foo.length); // 6
 substring(start[, end])Substring extracts characters from the start position
"hello".substring(1); // "ello"
"hello".substring(1, 3); // "el"