Created
September 25, 2018 20:38
-
-
Save ramsunvtech/a6e2007abcf24334bfe4dc00581f1a9d to your computer and use it in GitHub Desktop.
Simple Closure Example
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
function init() { | |
var a = []; | |
function airPlane(val) { | |
a.push(val); | |
return a; | |
} | |
return airPlane; | |
} | |
var airPlane = init(); | |
airPlane("Jask"); // Jack | |
airPlane("Jane"); // Jack, Jane |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment