Skip to content

Instantly share code, notes, and snippets.

@oHaiyang
Created April 8, 2016 05:16
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 oHaiyang/c25705f683bcabfc18d9d1cd26126a54 to your computer and use it in GitHub Desktop.
Save oHaiyang/c25705f683bcabfc18d9d1cd26126a54 to your computer and use it in GitHub Desktop.
function wrapValue(n) {
return function() {
return n += 2;
};
}
var wrap1 = wrapValue(1);
console.log(wrap1()); //-> 1
console.log(wrap1());
//为什么每被多执行一次,wrap1()的返回值就会增大呢?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment