Page 233 - Web_Application_v2.0_C12_Fb
P. 233

document.getElementById("demo1").innerHTML = text.search("fox");
                    </SCRIPT>

                    </BODY>
                    </HTML>
                 Output:
















                 12. The + Operator: The + operator in strings is used to concatenate (join) strings in JavaScript. It combines two
                    or more strings into one.

                 Example 42: To demonstrate the use of + Operator in strings
                    <!DOCTYPE HTML>

                    <HTML>
                    <HEAD>
                    <TITLE>+ Operator in Strings</TITLE>
                    </HEAD>

                    <BODY>
                    <H2>The + Operator in Strings</H2>
                    <P>The + operator joins two or more strings.</P>
                    <P id="demo1"></P>
                    <SCRIPT>

                    var text1 = "Hello";
                    var text2 = "World";
                    document.getElementById("demo1").innerHTML = text1 + " " + text2;

                    </SCRIPT>
                    </BODY>
                    </HTML>
                 Output:

















                                                                                                  JavaScript Part 2  231
   228   229   230   231   232   233   234   235   236   237   238