티스토리 뷰


//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." );

댓글
D-DAY
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함