function partition(f, li, ys=[], zs=[]) {
  if (li.length === 0) return [ys, zs]
  const [x, ...xs] = li 
  return (f(x)) 
    ? partition(f, xs, [...ys, x], zs)
    : partition(f, xs, ys, [...zs, x])
}

const [a, b] = partition(x => x%2==0, [0,1,2,3,4,5])
console.log(a, b)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: