DEV Community

Discussion on: Modern JavaScript, 10 things you should be using, starting today

Collapse
 
atinypixel profile image
Aziz Kaukawala • Edited

Great post! 5th & 10th points were my major take away! Thanks!


I don't know if this would be helpful.

For defining constants, instead of regular object,

const config = {
    APP_ENV: 'local',
    API_TOKEN: 'BREWING_SOMETHING_AWESOME',
}
Enter fullscreen mode Exit fullscreen mode

define constants with Object.freeze().

const config = Object.freeze({
    APP_ENV: 'local',
    API_TOKEN: 'BREWING_SOMETHING_AWESOME',
});
Enter fullscreen mode Exit fullscreen mode

This way, you won't be able to change the entries accidentally.

Happy Coding ๐Ÿงก