Another category of operator is the string operators, which only contain two operators. We've already seen the string operator + , which we used to concatenate (join) strings together: <HTML> <HEAD> <TITLE> Working With Strings </TITLE> </HEAD> <BODY> <H1>Working With Strings</H1> <SCRIPT LANGUAGE="JavaScript"> <!-- var text = "Here " + "is " + "the " + "text!" document.write("The text: " + text + "<BR>") document.write("The length of the text: " + text.length + "<BR>") document.write("In upper case: " + text.toUpperCase() + "<BR>") document.write("In lower case: " + text.toLowerCase() + "<BR>") document.write("In italics: " + text.italics() + "<BR>") document.write("Location of 'the': " + text.indexOf("the") + "<BR>") document.write("Replacing is with isn't: " + text.replace("is", "isn't") + "<BR>") if(navigator.appName == "Netscape") { document.write("The third letter is: " + text[2] + "<BR>") } // --> </SCRIPT> </BODY> </HTML> You also can use the shorthand assignment operator += to concatenate strings, and that's the other string operator. If the variable myText holds the value "Now is the " , the expression myText += "time." is evaluated to "Now is the time." and assigns this string to myText . |