mozilla

Compare Revisions

String

Change Revisions

Revision 54301:

Revision 54301 by Maian on

Revision 54302:

Revision 54302 by Hongli on

Title:
String
String
Slug:
JavaScript/Reference/Global_Objects/String
JavaScript/Reference/Global_Objects/String
Tags:
JavaScript, NeedsBrowserCompatibility, "JavaScript Reference", NeedsMobileBrowserCompatibility, Fixit, MakeBrowserAgnostic
JavaScript, NeedsBrowserCompatibility, "JavaScript Reference", NeedsMobileBrowserCompatibility, Fixit, MakeBrowserAgnostic
Content:

Revision 54301
Revision 54302
tt98    <h4 name="Comparing_strings">
99      Comparing strings
100    </h4>
101    <p>
102      C developers have the <code>strcmp()</code> function for co
 >mparing strings. In JavaScript, you just use the less-than and gr
 >eater-than operators:
103    </p>
104    <pre class="eval">
105var a = "a";
106var b = "b";
107if (a &lt; b) // true
108    document.write(a + " is less than " + b);
109else if (a &gt; b)
110    document.write(a + " is greater than " + b);
111else
112    document.write(a + " and " + b + " are equal.");
113</pre>

Back to History