Last active
November 28, 2017 07:36
-
-
Save deden/d5482b576a5305d31fade6cc7a61bb75 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// returns: undefined | |
// explanation: an empty block with an implicit return | |
((name) => {})() | |
// returns: 'Hi Jess' | |
// explanation: no block means implicit return | |
((name) => 'Hi ' + name)('Jess') | |
// returns: undefined | |
// explanation: explicit return required inside block, but is missing. | |
((name) => {'Hi ' + name})('Jess') | |
// returns: 'Hi Jess' | |
// explanation: explicit return in block exists | |
((name) => {return 'Hi ' + name})('Jess') | |
// returns: undefined | |
// explanation: a block containing a single label. No explicit return. | |
// more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label | |
((name) => {id: name})('Jess') | |
// returns: {id: 'Jess'} | |
// explanation: implicit return of expression ( ) which evaluates to an object | |
((name) => ({id: name}))('Jess') | |
// returns: {id: 'Jess'} | |
// explanation: explicit return inside block returns object | |
((name) => {return {id: name}})('Jess') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment