Created
February 12, 2013 19:26
-
-
Save Sljubura/4772566 to your computer and use it in GitHub Desktop.
Self-defining functions.
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
// Self-defining functions | |
var greetings = function () { | |
console.log("Hello!"); | |
greetings = function () { | |
console.log("Goodbye!"); | |
} | |
}; | |
greetings(); // Hello! | |
greetings(); // Goodbye! | |
// Note that if you assign 'greetings' to another variable, | |
// that second variable will always point to the last 'greetings' state. | |
var goodbye = greetings; | |
goodbye(); // Goodbye! | |
goodbye(); // Goodbye! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment