The statement in your .filter() function returns 3 , 0 , undefined , which in the world of truth / falsity are true , false , false . This means that the return from the .filter() function is [3] .
If you want to return all integer values, use the following:
var a1 = arr.filter(function(f) { return Number.isInteger(f); });
This will return [3,0] from the .filter() function.
Brett DeWoody
source share