Compare the char value : charAt « String « JavaScript Tutorial






<HTML>
<BODY>
<SCRIPT language="JavaScript">
<!--
var the_name="abc";
first_char=the_name.charAt(0);

if (first_char=="S") {
    document.write(the_name);
} else {
    document.write(first_char);
}

//-->
</SCRIPT>

</BODY>

</HTML>








6.9.charAt
6.9.1.String.charAt()
6.9.2.Get char in a string by index
6.9.3.Compare the char value