Back to feed
Renewal·서른의 생활코딩

Sample source 3) Basic JavaScript document structure ( string object _ applied 2 )

NS
normalstory
cover image

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>

This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.

More on the author's page

Keep reading

Renewal

Why You Should Use .html Instead of .md Seeing Is Believing

Jul 25, 2026·1 min
Renewal

The Most Important Thing About AX

Jul 17, 2026·2 min
Renewal

디지털 기술과 혁신에 대한 논고(지탱하는 힘)

Jul 17, 2026·5 min