JavaScript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




String Function - length()


Tutorials Javascript

Topic

function or method to find the length or size of the string in javascript?



Explanation

Object: String

Method or Function: length

Description: This will count the total number of characters (length or size) present in the string and returns the value.


Example Code:
<script language=javascript>
var ss = "a character count - size test ";
var result = ss.length;
document.write(result);
</script>

Result:

Explanation:
In the above example,
  • the string is stored in a variable ss.
  • then the function is called as "ss.length".
  • the method counts the total characters in the string and returns it.
  • the result is of variable type, integer.





  • A Note
    Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

    Other Links

    web hosting