Skip to content

Instantly share code, notes, and snippets.

@dmsnell
Last active January 5, 2016 06:19
Show Gist options
  • Save dmsnell/a62695a630f7fede347c to your computer and use it in GitHub Desktop.
Save dmsnell/a62695a630f7fede347c to your computer and use it in GitHub Desktop.
What will the following script spit out?
const l = m => console.log( m );
console.clear();
const a = () => { l( 'a ran' ); return 'a'; };
const b = () => { l( 'b ran' ); return 'b'; };
const c = false
? a()
: b();
l( 'Ternary test: ' + c );
const d = [ a(), b() ].slice(0, 1).join( ', ' );
l( 'List test: ' + d );
const e = ((...args) => args.slice( 1 ).join( ', ' ))( a(), b() );
l( 'Arg test: ' + e );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment