Skip to content

Instantly share code, notes, and snippets.

@gerhardberger
Created March 5, 2016 11:54
Show Gist options
  • Save gerhardberger/faa6d37dcc8285499055 to your computer and use it in GitHub Desktop.
Save gerhardberger/faa6d37dcc8285499055 to your computer and use it in GitHub Desktop.
// $ node --harmony_destructuring match.js -5
'use strict'
let x = Number(process.argv[2])
let { true: a } = {
[ x > 0 ]: 1,
[ x < 0 ]: -1,
[ x === 0 ]: 'wow'
}
console.log(a)
let match = o => {
let { true: a } = o
return a
}
let b = match({
[ x > 0 ]: 1,
[ x < 0 ]: -1,
[ x === 0 ]: 'wow'
})
console.log(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment