This time, let's run an example that uses the methods on the string object
to play with text.
Compared to the earlier examples that checked emails or Korean ID numbers, the result is more modest.
B.U.T.
you'll come to feel that this is a totally important object as you use JS more.
The bigger your programming gets,
especially
when you use, leverage, or build directly with big and famous libraries like JQuery or JQuery Mobile,
you'll be able to handle
transforming, using, and accessing many variables, or directly modifying tags inside the html document, or...
well.. all sorts of practical features like that.
Will you?
...Honestly.
Looks like you will... I haven't done it that much myself either... lol I just talked too much.. ha
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>substr / replace</title>
<script type="text/javascript">
//<![CDATA[
//substr
var str1,str2;
str1 = new String("JavaScript");
str2 = "DOMScript";
document.write(str1.substr(0,4)+"<br />");
document.write(str2.substr(3,6)+"<br />");
document.write(str2.substr(3)+"<br />");
// If you omit the length, it goes to the end of the string..
document.write(str1.replace("java","DOM")+"<br />");
//]]>
</script>
</head>
<body>
</body>
</html>
