Skip to content

Instantly share code, notes, and snippets.

@adccb
adccb / post.md
Created March 12, 2018 21:55
Javascript Pipeline Operators & Partial Application

javascript is about to get a pipeline operator (Goddess willing). here's why that's such a great thing, especially when combined with partial application & higher-order functions.

first off, let's talk about what the pipeline operator actually is, and why you should be so excited by it.

const lower = str => str.toLowerCase()
const stripWhiteSpace = str => str.replace(/[\s]+/g, '_')

const normalizedString = stripWhiteSpace(lower('    HELLO, worLD'))
 // 'hello, world'
@adccb
adccb / switch.js
Created March 20, 2018 16:07
switch nonsense
const someVar = 'foo'
// the bad way
switch(someVar) {
case foo:
const response = 'someVar is foo!'
break
case bar:
const response = 'someVar is bar!' // errors, 'assigning to constant variable response'