티스토리 뷰
//Exposing the properties of the katana object using with(){}.
var use = "other";
var katana = {
isSharp: true,
use: function(){
this.isSharp = !this.isSharp;
}
};
with ( katana ) {
assert( true, "You can still call outside methods." );
isSharp = false;
use();
assert( use !== "other","Use is a function, from the katana object." );
assert( this !== katana,"this isn't changed - it keeps its original value" );
}
assert( typeof isSharp === "undefined","Outside the with, the properties don't exist." );
assert( katana.isSharp,"Verify that the method was used correctly in the with." );
'웹개발 > Javascript' 카테고리의 다른 글
| 자바 스크립트 String 메서드 Split , Join 사용 예 (0) | 2010.12.14 |
|---|---|
| 자바스크립트 여러가지 (0) | 2010.09.10 |
| 자바스크립트 정규식 예제 (0) | 2010.09.10 |
| 자바스크립트 함수, Timer 사용하기 (0) | 2010.09.10 |
| 템플릿 메서드 패턴 (0) | 2010.07.15 |
댓글