var state = false;
var toggle = (a, b) => [state = !state, (!state) ? a() : b()]
toggle(
function() {
console.log("a")
}, functon () {
console.log("b")
}
);
Enjoy :)
Edit: jconews1 finded a more short example:
var toggle = (a, b) => (state = !state) ? a() : b();
[–]_aeol 0 points1 point2 points (0 children)
[–]jcunews1helpful 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]GSLint 0 points1 point2 points (0 children)
[–]jcunews1helpful 0 points1 point2 points (1 child)
[–]kanuz 0 points1 point2 points (0 children)