Created
June 8, 2010 00:37
-
-
Save mapiondev/429431 to your computer and use it in GitHub Desktop.
[javascript] strategyパターン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isIE() { | |
return false; | |
} | |
function isMoz() { | |
return false; | |
} | |
function isOpera() { | |
return true; | |
} | |
var fn = isIE() ? function() { | |
console.log("ie"); | |
} : isMoz() ? function() { | |
console.log("moz"); | |
} : isOpera() ? function() { | |
console.log("opera"); | |
} : function() { | |
console.log("other"); | |
}; | |
fn(); // opera |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment