JavaScript const Keyword

前端 未结 8 1696
自闭症患者
自闭症患者 2020-12-09 13:25

Does the const keyword in JavaScript create an immutable reference to immutable data structures? [I\'m assuming that immutable data structures exist in JavaScri

8条回答
  •  一个人的身影
    2020-12-09 14:03

    Wrong. It is not immutable, from the MDN Documentation for const:

    The const declaration creates a read-only reference to a value. It does not mean the value it holds is immutable, just that the variable identifier cannot be reassigned.

提交回复
热议问题