javascript - How to resolve this " Uncaught TypeError: Cannot convert undefined or null to object " -


my function :

function collect_que_ids(e) {   var val = e.val();   var data_lo = e.attr('data-lo');   new_hash = {};   new_hash[val] = data_lo;   if(e.is(':checked')){     if(checked_box_hash.includes(new_hash)){       checked_box_hash;     }else{       checked_box_hash.push(new_hash);     }   }   else{     new_hash_key = object.keys(new_hash)[0]     new_hash_value = new_hash[new_hash_key]     $.each(checked_box_hash, function(key, value){       if (typeof object.keys(value) !== 'nil') {         current_key = object.keys(value)         if (current_key[0] == new_hash_key && value[current_key[0]] == new_hash_value) {           checked_box_hash.splice(key, 1)         }       }     })   } }; 

i getting error on line.

if (typeof object.keys(value) !== 'nil') { 

need resolve it. please do.

object.keys(value) returns array , check if undefined or empty this

 if (typeof object.keys(value) !== 'undefined' && object.keys(value).length > 0) {         // have array      } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -