The JavaScript length character length function, we use the length function for a lot of time, because you have to have the front desk judge whether a user's username and password length is what I want to specify.
Advanced scripters often need to know how long a JavaScript string is. For example, if a webdeveloper is to create a submit form that requires the user to no longer exceed 20 characters, then she will need to check the length of the string before allowing the user to submit the data.
String length
The Length property returns the number of characters in a string, with an integer. The following is the basic code used to access this property.
<script type= "Text/javascript" >
var myString = "123456";
var length = mystring.length;
document.write ("The string is this long:" + length);
Same thing, but using the property inside the Write function
document.write ("<br/>the string is this long:" + mystring.length);
</script>
String Changed? Length might change
if you refer to the length of the property, concatenating (add) certain characters of the string, and then the length of the property will reflect these changes. Think of this as a friendly reminder will only check the length of the string after you are sure it is not going to change the
<script type= "Text/javascript"
var myString = "123456";
document.write ("The string is this long:" + mystring.length );
myString = myString + "7890";
document.write ("<br/>the string is now" long: "+ mystring.length );
</script>
Output 6,10