Are there constants in JavaScript?

后端 未结 30 2600
抹茶落季
抹茶落季 2020-11-22 08:53

Is there a way to use constants in JavaScript?

If not, what\'s the common practice for specifying variables that are used as constants?

30条回答
  •  心在旅途
    2020-11-22 09:35

    No, not in general. Firefox implements const but I know IE doesn't.


    @John points to a common naming practice for consts that has been used for years in other languages, I see no reason why you couldn't use that. Of course that doesn't mean someone will not write over the variable's value anyway. :)

提交回复
热议问题