Constant values can be defined within a class using the keyword const.



const myConstant = "Constant Value";


  • Remain the same and unchangeable
  • Do not use the $ symbol
  • Must be a constant expression
    • not a class's property, result of a mathematical operation or a function call

Example showing a const being defined within the class, then being called from within the class and again externally:

Save & refresh browser:

Constructor: constant value
constant value

Leave a Reply