fp.js
function compact(list,typ) {
    if(arguments.length === 1) {
      if (Array.isArray(list)) {
        // if the only one param is an array
        return list.filter(x=>x);
      } else {
        // Curry it manually
        typ = list;
        return function (list) {return compact(list, typ)};
      }
    }
    return list.filter(x=> typeof x === typeof typ);
  }
function compact(list,typ) {
    if(arguments.length === 1) {
      if (Array.isArray(list)) {
        // if the only one param is an array
        return list.filter(x=>x);
      } else {
        // Curry it manually
        typ = list;
        return function (list) {return compact(list, typ)};
      }
    }
    return list.filter(x=> typeof x === typeof typ);
  }
function compact ( list , typ ) { if ( arguments . length === 1 ) { if ( Array . isArray ( list ) ) { // if the only one param is an array return list . filter ( x => x ) ; } else { // Curry it manually typ = list ; return function ( list ) { return compact ( list , typ ) } ; } } return list . filter ( x => typeof x === typeof typ ) ; }
Returns truthy values from an array.
When typ is supplied, returns new array of specified type
Returns truthy values from an array . When typ is supplied returns new array of specified type