Open ajhsu opened 6 years ago
Every module (such as a process, a user, or a program, depending on the subject) must be able to access ONLY the information and resources that are necessary -- for its legitimate purpose.
https://en.wikipedia.org/wiki/Principle_of_least_privilege
從 TypeScript 文件上讀到的: 為何 JavaScript 偏好 const 多於 let?
const
let
根據上述的 Principle of least privilege 規則 我們只需要給出一個模組 可以完成需求的最低權限 即可
因此,在一個變數沒有明確需要被修改、覆寫的情況下,預設給出 const (即 readonly) 的權限即可
Ref: https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Variable%20Declarations.md#let-vs-const
Definition
Every module (such as a process, a user, or a program, depending on the subject) must be able to access ONLY the information and resources that are necessary -- for its legitimate purpose.
Source
https://en.wikipedia.org/wiki/Principle_of_least_privilege