Last active
December 18, 2015 12:49
-
-
Save ultim8k/5785698 to your computer and use it in GitHub Desktop.
A simple javascript function template
This file contains hidden or 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
/** | |
* A simple javascript function template; | |
*/ | |
// Define the function | |
var functionName = function(args){ | |
var options; | |
var exec; | |
if (typeof arguments[0] == "object") { | |
options = arguments[0]; | |
exec = arguments[1]; | |
} else { | |
options = {}; | |
exec = arguments[0]; | |
} | |
if(exec){ | |
exec(options); | |
}else{ | |
console.log(options); | |
} | |
return false; | |
}; | |
// run the function | |
functionName({a:3,b:4}, function(data){ | |
console.log(data.a + data.b); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment