Daily JavaScript Tips #1

Daily JavaScript Tips #1

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