re: ES6 Arrow Functions Cheatsheet VIEW POST

FULL DISCUSSION
 
 

I just want to show the parameters being used. But I can see how this is confusing. One shouldn't return with a , for sure. But for those wondering why, see below for the output of this function:

const someFunc = (a, b) => {
  return a, b
}

someFunc('a', 'b'); // 'b'
// It returns only the last argument
 

No, the real WUT is this:

let fn = (a, b) => a, b
fn('a','b') // It won't be 'b' :)

fn = (a, b) => (a, b)
fn('a','b') // Now it will.

// Honorable mention:
fn = ((a, b) => a, b)
fn('a','b') // Uncaught TypeError: fn is not a function
// (It's actually the `undefined` `b` declared at line 1:23)
// How excellent is that?!
code of conduct - report abuse