Created
June 12, 2012 22:07
-
-
Save iruslani/2920427 to your computer and use it in GitHub Desktop.
Basic Javascript function Syntax.
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
// A simple function | |
var greet = function(person, greeting) { | |
var text = greeting + ', ' + person; | |
console.log(text); | |
}; | |
greet('Iwan', 'Hello'); | |
// A Function that returns a value | |
var greet = function(person, greeting) { | |
var text = greeting + ', ' + person; | |
return text; | |
}; | |
console.log(greet('Iwan','hello')); | |
// A Function that returns another function | |
var greet = function(person, greeting) { | |
var text = greeting + ', ' + person; | |
return function() { console.log(text); }; | |
}; | |
var greeting = greet('Iwan', 'Hello'); | |
greeting(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment