+ 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()) ;
1 Réponse
+ 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;