Skip to content

Instantly share code, notes, and snippets.

@mannuelf
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mannuelf/c320eddf1453815859ea to your computer and use it in GitHub Desktop.
Save mannuelf/c320eddf1453815859ea to your computer and use it in GitHub Desktop.
Define a Function
// function constructor : the last paramater is the function logic, everything before it is a paramater
var theConstructor = new Function('x', 'y', 'return x + y');
// function statement
function theStatement(x, y) {
return x + y
};
// function expression
var theExpression = function(x, y) {
return x + y;
};
console.log(theConstructor(2,2), theStatement(2,2), theExpression(3,3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment