Length property in Javascript

Posted by vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 1210
Length property will give as the number of characters in the string;

For ex:-

<script type="text/javascript">
function get_length()
var str = "abcdef";
document.write("before appending new string: " + str.length);


str = str + "pqr";
document.write("after appending new string: " + str.length);

<asp:Button ID="btn_check" runat="server" Text="Check Length" OnClientClick="get_length();" />

Output will be :-
before appending new string: 6
after appending new string: 9

So it's an easy way to get length in Javascript.

Comments or Responses

Login to post response