//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 origin..
function RegMerge() { var expr = []; for ( var i = 0; i < arguments.length; i++ ) expr.push( arguments[i].toString().replace(/^\/|\/\w*$/g, "") ); return new RegExp( "(?:" + expr.join("|") + ")" ); } var re = RegMerge( /Ninj(a|itsu)/, /Sword/, /Katana/ ); assert( re.test( "Ninjitsu" ),"Verify that the new expression works." ); assert( re.test( "Katana" ),"Verify that the new expression works." )..
* 함수의 사용 function isNimble(){ return true; } var canFly = function(){ return true; }; window.isDeadly = function(){ return true; }; //함내의 함수 function stealthCheck() { var ret = stealth() == stealth(); assert( ret, "함수함수!" ) return true; function stealth(){ return true; } } stealthCheck(); var obj = {}; var fn = function(){}; obj.prop = "some value"; fn.prop = "some value"; assert( obj.prop == fn..