jquery - Filtering out null values of object list in JavaScript -


i filtering out null values array using object.keys , map this:

// ultimate goal length of list !== null var length = object.keys(mylist).map(x => mylist[x]).filter(x => x !== null).length; 

i need find alternative way of doing because in ie11 having issues it. interfering functionality of 3rd party control somehow.

any ideas?

the arrow functions not supported in ie. , equivalent of code is:

var mylist = {'1': '1', '2': '2', '3': '3', '4': null};  var length =   object.keys(mylist).map(function (x) {    return mylist[x]  }).filter(function (x) {    return x !== null;  }).length;    console.log(length);

because output of object.keys(mylist) array , need filter elements vaues (not null) may reduce to:

var mylist = {'1': '11', '2': '22', '3': '33', '4': null};  var length =   object.keys(mylist).filter(function (x) {    return mylist[x] !== null;  }).length;    console.log(length);


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -