Retrieve value from nested functions javascript -


i have had look, , see great examples of nesting functions, reading them, cannot see why getting undefined when call function:

function readbttndetec() {     var devid = localstorage.getitem('vbttn');     var bd = 0;     bd = ble.read(devid, 'fffffff0-00f7-4000-b000-000000000000',              'fffffff2-00f7-4000-b000-000000000000',               function(t) {                   var data = new uint8array(t)                   console.log('returns: ' + data[0]); // returns 6                   return data[0];              }, function(f) {                  console.log(f);                      });                  return bd; } 

this call:

//check button state         var detecs = readbttndetec();         console.log(detecs);         if(detecs == 2) {             // fall detection disabled                   $('#playfall').removeclass('km-state-active');             } else if(detecs == 6) {             // fall detection enabled             $('#playfall').addclass('km-state-active');         } else {             // error reading button         } 

i missing simple sure of it, cannot see it.

thanks in advance


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -