Return to Kroll Web Design home page

JavaScript Tutorials

« Return

length property (strings)

To determine the length of a string, that is, to determine how many characters the string currently contains, look at the "length" property of the string.

Code:

<script type="text/javascript">
//<![CDATA[
my_string = "A Historic Inauguration";
document.write("The length of \"", my_string, "\" is : ", my_string.length);
//]]>
</script>

Output:




©2010 Kroll Web Design    davidarthurkroll@verizon.net    781.910.3694