Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Use const whenever possible #14

Closed
elisee opened this issue Jan 8, 2016 · 1 comment
Closed

Use const whenever possible #14

elisee opened this issue Jan 8, 2016 · 1 comment

Comments

@elisee
Copy link
Contributor

elisee commented Jan 8, 2016

We've been using let for declaring variables almost everywhere. This is a good thing, as it is better-behaved than var (yay for block-scoping!).

But ES6 / TypeScript actually comes with const keyword. As a general rule, we should use it whenever possible, that is, whenever the variable identifier isn't meant to be reassigned.

Rationale: It will make variable identifiers that are meant to be reassigned easier to locate, and will reduce the likelihood of accidental reassignements.

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.

Doing this in the whole codebase all at once might be a pain, so feel free to submit a pull request that just takes care of a file or two. Over time, we'll get there.

@abclive
Copy link

abclive commented Jan 8, 2016

I will have a look at it :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants