Skip to content

Instantly share code, notes, and snippets.

@kylebakerio
Last active August 29, 2015 14:25
Show Gist options
  • Save kylebakerio/2322836a34c2dc75c80d to your computer and use it in GitHub Desktop.
Save kylebakerio/2322836a34c2dc75c80d to your computer and use it in GitHub Desktop.
function param7(param) {
return param + 7;
}
1 === 2 ?
console.log("statement 1 passes") :
1 === 3 ?
console.log("statement 2 passes") :
1 === 1 ?
function(){
console.log(param7("ten"));
console.log("llama");
}() :
console.log("no statement passes");
@kylebakerio
Copy link
Author

So, functional programming/chains of functions can be used.

But...

experimenting with this some more, I'm a little confused as to why I can't just insert a block statement with multiple commands inside, a la

1 === 1 ?
    {
        param7("ten");
        console.log("llama");
    }:
1 === 3 ?
    console.log("statement 2 passes") :
1 === 4 ? 
    console.log("statement 3 passes") :
console.log("no statement passes")

Looking them up here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block

confirms what I thought I had read, namely, that they're legal anywhere, basically. I guess rather than 'executing' the block, it tries to 'return' it? reaching at straws...

@kylebakerio
Copy link
Author

ok, back to real work for now, I guess.

@kylebakerio
Copy link
Author

ah ha... thought of this while in bed last night... you can use an anonymous function that is executed upon declaration as a block statement, basically (see current version).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment