Skip to content

Instantly share code, notes, and snippets.

@ladushki
ladushki / defaults-overrides.md
Created December 11, 2018 06:14 — forked from ericelliott/defaults-overrides.md
ES6 defaults / overrides pattern

ES6 Defaults / Overrides Pattern

Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.

function foo ({
    bar = 'no',
    baz = 'works!'
  } = {}) {
@ladushki
ladushki / essential-javascript-links.md
Created December 11, 2018 06:13 — forked from rsperberg/essential-javascript-links.md
A fork that adds descriptions to Eric Elliott’s 142 essential JS links
@ladushki
ladushki / .gitignore
Created December 11, 2018 06:12 — forked from ericelliott/.gitignore
Sample Node project .gitignore
node_modules
build
npm-debug.log
.env
.DS_Store
@ladushki
ladushki / toslug.js
Created December 11, 2018 06:11 — forked from ericelliott/toslug.js
Naive toSlug
const toSlug = input => encodeURIComponent(
input.split(' ')
.map(str => str.toLowerCase())
.join('-')
);
@ladushki
ladushki / wait.js
Created December 11, 2018 06:10 — forked from ericelliott/wait.js
Wait -- an ES6 promise example
const wait = time => new Promise((resolve) => setTimeout(resolve, time));
wait(3000).then(() => console.log('Hello!')); // 'Hello!'
@ladushki
ladushki / filter.js
Created December 11, 2018 06:09 — forked from ericelliott/filter.js
Filter implemented with reduce
const filter = (fn, arr) => arr.reduce((newArr, item) => {
return fn(item) ? newArr.concat([item]) : newArr;
}, []);