Skip to content

Instantly share code, notes, and snippets.

@mapiondev
Created June 8, 2010 00:37
Show Gist options
  • Save mapiondev/429431 to your computer and use it in GitHub Desktop.
Save mapiondev/429431 to your computer and use it in GitHub Desktop.
[javascript] strategyパターン
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