Skip to content

Instantly share code, notes, and snippets.

@ultim8k
Last active December 18, 2015 12:49
Show Gist options
  • Save ultim8k/5785698 to your computer and use it in GitHub Desktop.
Save ultim8k/5785698 to your computer and use it in GitHub Desktop.
A simple javascript function template
/**
* 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