+ 1

JS code from challenge

Hello Guys, I'm not sure about this code. Can someone explain me why the output is "x" please? <script> (function(x) { return(function(y) {alert(x); }) (); })("x") </script>

15th Sep 2017, 9:02 AM
Babihac
Babihac - avatar
3 Answers
+ 3
This is probably one of the most interesting concept in Javascript and once you fully understand it you'll become the master! Try Google:- Javascript Closure to study more about it. 😉
15th Sep 2017, 10:00 AM
Zephyr Koo
Zephyr Koo - avatar
+ 2
You're welcome Babihac! 😄
15th Sep 2017, 10:35 AM
Zephyr Koo
Zephyr Koo - avatar
+ 1
Thank you for the worthwhile advice. I will check it soon :D
15th Sep 2017, 10:07 AM
Babihac
Babihac - avatar