+ 1

stack while dealing with default parameters...... Uncaught SyntaxError: Invalid destructuring assignment target

Let x = { a:1, b:2 } ; let add = ({a:0, b:0} = {} ) =>{ return a+b; } console.log(add()) ;

26th Jun 2019, 11:37 AM
Boaz Nyagaka
Boaz Nyagaka - avatar
1 Respuesta
+ 3
When destructing, after the : is the name of the variable, and 0 isn't a valid name. I think you are looking for: let add = ({a, b} = {a: 0, b: 0}) => a + b;
26th Jun 2019, 11:43 AM
Airree
Airree - avatar