How to call javascript methods that are not in scope but utilise .call(this) -


i unsure on how call these functions such inventorycheck in web browser (chrome) console when seems not visible. there way can call this? thanks!

below snippet of javascript file.

(function() {     var cc, addtobagcheck, addtocarterror, addtocartrequest, addtocartsuccess, availablesizes, displaycorrectshoe, inventorycheck, isvalidjson, processinventory, selectsize, showbuy, showerror, showsoldout,         slice = [].slice,         bind = function(fn, me) {             return function() {                 return fn.apply(me, arguments);             };         };      inventorycheck = function() {         return availablesizes(function(product) {             return processinventory(product);         });     };      window.captcharesponse = function(response) {         $('#captcha').addclass('checked');         $('#flashproductform').append('<input class="captcha-duplicate" type="hidden" name="x-prdrt" value="' + response + '">');         return addtobagcheck();     };  }).call(this); 

you cannot. inventorycheck defined inside closure. in order call them globally (like in console), must define them on window object. since closure appears have window context (by calling using this context), can define inventorycheck like:

this.inventorycheck = function(){...} 

note defining stuff on global object bad idea. consider attaching single global object own. reduces footprint on global object single object. following pattern better:

;(function(ns){    ns.inventorycheck = function(){...}    // rest of code  })(this.myglobal = this.myglobal || {});  // usage  myglobal.inventorycheck(...); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -