- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <!-- 현재 작성하고 있는 파일은 UTF-8 DOS파일입니다.-->
- <html xmlns="http://www.w3.org/1999/xhtml" lang="ko">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- </head>
- <body>
- <div id="ex_js_syntax">
- <script type="text/javascript" language="javascript">
- <!--
- function str_prototype(){
- /* prototype 임의의 타입으로 정의 */
- function people_info(names,address,born){
- this.names=names;
- this.address=address;
- this.born=born;
- }
- var pp1 = new people_info("로이","서울",2000);
- people_info.prototype.sex=null;
- pp1.sex="남";
- var string_pp1 = "이름 :"+pp1.names+" 사는곳: "+pp1.address+" 태어난연도: "+pp1.born+" 성별: "+pp1.sex;
- document.getElementById("string_prototype").innerHTML=string_pp1;
- }
- //-->
- </script>
- <form name="input_type" id="input_type" method="post" >
- <!-- 예제 박스에선 안됨 => form태그안에 form태그있으면 지워짐~ㅠ.ㅠ -->
- <p id="string_prototype" onclick="str_prototype();">프로토타입[클릭]</p>
- </form>
- </div>
- </body>
- </html>
--------------------------------------------------------------------------------------------
위 소스 예제 보기
문자열의 프로토타입 - 임의의 타입으로 정의해서 처리하는 것입니다.
출처 & 인용 - http://www.w3schools.com/
'javascript > String()객체' 카테고리의 다른 글
String객체 fromCharCode() 문자열 아스키코드 문자 반환 (0) | 2014.02.01 |
---|---|
String객체 concat() 문자열 합치기 (0) | 2014.02.01 |
String객체 charCodeAt() 문자열 지정위치 아스키코드 반환 (0) | 2014.02.01 |
String객체 charAt() 문자열 지정위치 문자 반환 (0) | 2014.02.01 |
String객체 length 문자열 길이 반환 (0) | 2014.02.01 |