spacer
Web Development Tutorials JAVASCRIPT Tutorials
 Developer Newsletter

Tutorials
AJAX
ASP
CGI & Perl
CSS
Flash
HTML
Illustrator
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML
Miscellaneous


Scripts Directory
AJAX Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Web Hosting Directory
ASP.NET
Budget
Dedicated Servers
Ecommerce
Linux
Resellers
Shared
Small Business
Windows

Developer Manuals
Learn HTML
Learn PHP
Learn CSS
Learn AJAX
Learn JavaScript
Learn Pear
Free White Papers

Developer Resources
Developer Tools
Developer Content
Survey Software
Dedicated Servers




Finding the Length of a String in JavaScript

By Amrit Hallan
2005-10-19


Finding length of a string in JavaScript

When I used JavaScript to find the length of a string for the first time, I kept testing a function something like str.length(), whereas in JavaScript length is not a function, it is a property of the string object. So here is how you find the length of a string using length property of JavaScript:

<script language="javascript" type="text/javascript">

var str="When a dog bites it pains.";
alert(str.length);

</script>

The function alert() in this case should throw up 26. So make a mental note that to calculate the length of a string str in JavaScript, it is str.length and not str.length().



Tutorial Pages:
» Finding length of a string in JavaScript


 | Bookmark Print |   Write For Us
Related Tutorials:
» JavaScript Debugging Techniques with Firebug
» Striped Tables Using JavaScript
» Opening PDFs in a New Window with JavaScript
» Essential Javascript -- A Javascript Tutorial
» Submit Forms Conditionally using JavaScript
» How to Setup a Randomising Function



About the NetVisits, Inc Network | Write For Us | Advertise
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: