Comment

Comment by olalonde

Pretty cool. Few suggestions (which may or may not require babel):

- `f.apply(null, args)` calls can be replaced with `f(...args)`

- Your head function returns the first argument while your last function returns an array containing the last argument. I'd rewrite those functions as:

    const head = (x) => x;
    const last = (...xs) => xs[xs.length-1];
    const tail = (x, ...xs) => xs;
    const init = (...xs) => xs.slice(0, -1);
(Unfortunately it seems the rest operator can only appear as the last argument.)

- Why put everything on the prototype? It doesn't seem necessary since you are not using the `this` keyword. I would just stick the `export` keyword in front of functions to be exported.

Looking forward to part 2.

parent olalonde 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton