• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

String Operators

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> 

					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint