jquery - a javascript function called without arguments -


i trying understand javascript code.

banana.reloaduser being called inside function without arguments:

 function(data) {                 if (!data.result.success) {                     alert(data.result.message)                 } else {                      /*do something*/                      banana.testdata = data;                      banana.reloaduser();                 }  } 

banana.reloaduser defined this:

banana.extend({         reloaduser: function(cb, data) {              var = this,                 done = function(d) {                     $.extend(that.user, d);                     if ($.isfunction(cb)) {                         cb(d)                     }                     that.trigger("user.reloaded", [d])                 };             if (data) {                 done.apply(banana, [data])             } else {                 /*do something*/              }         }  }) 

'reloaduser' being called save userinfo data in localstorage. whenever user new account 'reloaduser' saves new information localstorage.

my question since banana.reloaduser being called without arguments how supposed pick arguments ?

note: part of big javascript/jquery code in case information not enough please ignore question.

the big javascript code contain function

banana.reloaduser(function() {                  try {                     banana.trigger('start', [$]);                 }catch(e) { }                  try {                     $('[data-deferred]').deferredimage();;                 }catch(e) { }             });              started = true;         }; 

if call javascript function without arguments parameters receive value of undefined (not null different value).

so calling

banana.reloaduser() 

is same as:

banana.reloaduser(undefined, undefined) 

in code ok, condition:

if ($.isfunction(cb)) { 

will fail because undefined not function, , later on condition:

if (data) { 

will fail because undefined treated equivalent false when appears somewhere boolean value expected.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -