English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
prototype속성은 속성과 메서드를 Date() 객체에 추가할 수 있습니다.
주의:prototype는 전역 속성으로 거의 모든 객체(숫자, 배열, 문자열, 날짜 등)에 사용할 수 있습니다.
Date.prototype.name = value
새로운 date 메서드를 생성하여 month-numeric 값이 month로 변환됩니다-name 값:
Date.prototype.showMonth = function() { var arr = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; return arr[this.getMonth()]; };
그런 다음 날짜를 생성하고 showMonth() 메서드를 호출하십시오:
var d = new Date(); var month = d.showMonth();// new 메서드 호출
모든 브라우저가 prototype 속성을 완전히 지원합니다:
속성 | |||||
prototype | Oui | Oui | Oui | Oui | Oui |