getify wrote:
IIUC, to apply default values per property in the params list, you need to destructure the object passed in (which btw you called
info
in one place andoptions
in the other). But you can't destructure in the params list AND then recombine into a single param name likeinfo
. That second step needs to be separate in the body of the function. Try this:var userInfo = ( {name = 'Mr.Coder', codes = ['js','python','ruby','perl']} ) => { let info = {name,codes}; console.log(info); } userInfo({ name: 'ljharb' });
I think that produces what you want. Image may be NSFW.
Clik here to view.