Default parameters: your code just got smarter
frontendmasters.com·2w
Preview
Report Post

Matt Smith with wonderfully straightforward writing on why default parameters for functions are a good idea. I like the tip where you can still do it with an object-style param.

function createUser({ name = 'Anonymous', age = 24 } = {}) { console.log(`${name} is ${age} years old.`); } cre...

Similar Posts

Loading similar posts...