Last active
January 18, 2017 21:59
-
-
Save bryanwoods/cec732b3568371f2734052a7fa4a2d99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RHS_OF_THE_BEAST = 246; | |
let ifLet = (binding, then) => { | |
let b = binding.slice(0, binding.indexOf("=")); | |
return eval(binding) && then.call(this, eval(b)); | |
}; | |
let fn = (y) => y + RHS_OF_THE_BEAST; | |
let reverseNumber = (number) => number.toString().split('').reverse().join(''); | |
[ | |
ifLet("x = 420", fn), | |
ifLet("foo = false", fn), | |
ifLet(`bar = ${reverseNumber(RHS_OF_THE_BEAST)}`, fn) | |
].map((expr) => console.log(expr)) | |
//=> 666 | |
//=> false | |
//=> 888 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment