Skip to content

Instantly share code, notes, and snippets.

@Risto-Stevcev
Created April 6, 2016 16:15
Show Gist options
  • Save Risto-Stevcev/bdeec5c4fdcce261a129f25a032ab505 to your computer and use it in GitHub Desktop.
Save Risto-Stevcev/bdeec5c4fdcce261a129f25a032ab505 to your computer and use it in GitHub Desktop.
where clause
// playing around with "where" clause functionality for JS
const def = fn => ({
where: obj => (function(obj) {
Object.keys(obj).forEach(key => this[key] = obj[key])
fn()
})(obj)
})
def(() => {
console.log(a + b)
}).where({ a: 2, b: 5 })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment