Skip to main content

Command Palette

Search for a command to run...

Daily JavaScript Tips #1

Published
β€’1 min read
Daily JavaScript Tips #1
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

Pass arguments as an object.

The code becomes much more clear and easily understandable as the name of the properties is clearly visible to you as well any code reviewer.

Don't do this ❌

const user = (name, email, proUser) => {
        // Logic goes here
}

user('SnowBit', 'xyz@someemail.zyx', true);

Do this βœ…

const user = ({name, email, proUser, isAdmin}) => {
        // Logic goes here
}

user({
    name: 'SnowBit', 
    email: 'xyz@someemail.zyx', 
    proUser: true,
    isAdmin: true
});

Thank you for reading

More from this blog

D

Dhairya Shah

119 posts