JavaScript 프로 토 타 입 개체

Object-Oriented JavaScript:Using the`Prototype'Property 는 JavaScript 1.1 부터 내 장 된 대상 을 Prototype 이 라 고 합 니 다.이 를 통 해 자 바스 크 립 트 를 확장 하여 대상 에 사용자 정의 속성 과 방법 을 작성 할 수 있 습 니 다.예 를 들 어 말 하 다.다음은 my Trim 이라는 방법 을 정의 하고 사용법 을 보 여 줍 니 다. String.prototype.myTrim = function(){ return( this.replace(new RegExp("^([\\s]+)|([\\s]+)$", "gm"), "") ); } document.getElementById("textbox").value = " This A Book ".myTrim (); 참조 링크:1. The prototype object of JavaScript2. Object-Oriented JavaScript: Using the `Prototype` Property

좋은 웹페이지 즐겨찾기