In Javascript functions and variables share same namespace and that is why this code will break
<script> function ThisIsAFunction(n) { alert(n); }; var ThisIsAFunction = 'India'; alert('abount to execute'); ThisIsAFunction('Hello'); </script> |
Basically 1st statement in code is similar to
var ThisIsAFunction = function ThisIsAFunction(n) { alert(n); };
Or
var ThisIsAFunction = = function (n) { alert(n); };
and this will collide even inside a closure as closure will be scope rather than global.