Why you should not use magic numbers in your Javascript and how to clean them up #shorts

Keep magic numbers out of your code base


🤑 Patreon https://www.patreon.com/webdevjunkie
🔔 Newsletter http://eepurl.com/hnderP
💬 Discord https://discord.gg/4kGbBaa
📁. GitHub https://github.com/codyseibert/youtube


  1. It's could be more practical if you use a dictionary? Like this:

    const PAYMENT_AMOUNT = {

    MIN: 1.99,

    MAX: 5.99


    if(payment > PAYMENT_AMOUNT.MAX) ….

  2. Thank you very much!! I love this short tutorial. You explain thing very well and easy to understand. Thank you again. Have an awesome weekend!!

  3. In short, you just never want to have anything, that may repeat elsewhere, or has an inapparent meaning, hardcoded without making use of constant values.

  4. This mechanism is used almost everywhere. We create a Constants.cs file in C# where in we put all the constants. Also we create enums to make things cleaner.

  5. I really need help with JavaScript 😂😂
    Just recently learnt to use a variable and now I have a better understanding with this
    Love the content

Leave a Reply

© 2023 53GB