17.2. Getting the Number
of Characters in a String: length() Function
The
length() function helps us get the number of characters in a
string. Its syntax is:
String.length(string);
If
the function call succeeds, length() returns the number of
characters contained in string. It returns invalid
if any error occurs.
The
following WMLScript examples demonstrate the use of length():
var
len = String.length("WMLScript Tutorial");
After
executing the above line of script, the len variable has the
value 18.
var
len = String.length(12345);
After
executing the above line of script, the len
variable has the value 5.
Feedback Form (ExpandCollapse)
|
|