javascript - Make a function accessible outside of a closure -


is there way make function created inside closure accessible outside of closure? i'm working air app , need provide access specialfunction() air closure keeping happening.

(function () {     ... bunch of code ..      function specialfunction() {         .. code     } }());  

you can assign function global object (which window in browsers):

(function () {     ... bunch of code ..      window.specialfuncton = function() {         .. code     } }()); 

this makes globally available.

if air application needs access other functions, better create namespace these functions:

var funcs = {}; // global  (function () {     ... bunch of code ..      funcs.specialfuncton = function() {         .. code     } }()); 

Comments