Created
June 8, 2018 13:18
-
-
Save colevandersWands/5162bd0ed78d7ba411e8b217e94fe0ad to your computer and use it in GitHub Desktop.
cooool cloosures
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
// https://goo.gl/JHrzXs | |
function cooool(num) { | |
function func_1() { | |
num++; | |
}; | |
function func_2() { | |
console.log(num); | |
}; | |
return [func_1, func_2]; | |
}; | |
let funcs_arr = cooool(0); | |
funcs_arr[0](); | |
funcs_arr[1](); | |
// function closer(arg) { | |
// let variable = 'var'; | |
// function closee_a() { | |
// console.log(arg); | |
// console.log(variable); | |
// }; | |
// function closee_b() { | |
// console.log(arg); | |
// console.log(variable); | |
// }; | |
// return [closee_a, closee_b]; | |
// }; | |
// let closed_funcs_3 = closer(3); | |
// let closed_funcs_4 = closer(4); | |
// closed_funcs_3[0](); | |
// closed_funcs_3[1](); | |
// closed_funcs_4[0](); | |
// closed_funcs_4[1](); | |
// // function closer(arg) { | |
// // let variable = 'var'; | |
// // function closee() { | |
// // console.log(arg); | |
// // console.log(variable); | |
// // }; | |
// // return closee; | |
// // }; | |
// // let func_w_closed_value_3 = closer(3); | |
// // let func_w_closed_value_4 = closer(4); | |
// // func_w_closed_value_3(); | |
// // func_w_closed_value_4(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment