Opened 15 months ago

Last modified 15 months ago

#26184 new task

Think about using `const` as much as possible in Torbutton code

Reported by: gk Owned by: tbb-team
Priority: Medium Milestone:
Component: Applications/Tor Browser Version:
Severity: Normal Keywords: tbb-torbutton
Cc: igt0, arthuredelstein Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

While working on #24309, the idea got brought up to use const as much as possible in Torbutton code (see: https://github.com/arthuredelstein/torbutton/commit/3a1aa3ff006b3f2d2e49931c71f9ec2661143192 for an actual patch for the circuit display).

We should summarize the pros and cons for this idea and then make a decision on what to do and do it.

Child Tickets

Change History (2)

comment:1 Changed 15 months ago by mcs

I am not sure if we should use const everywhere we can. Is Mozilla doing this? Here is an article that makes for interesting reading; especially look at the "Liberal let" and "Constantly const" sections: https://madhatted.com/2016/1/25/let-it-be

What to do probably comes down to personal preference, but as a team it would be good to adopt some guidelines.

Last edited 15 months ago by mcs (previous) (diff)

comment:2 Changed 15 months ago by igt0

Hi I also like this article https://mathiasbynens.be/notes/es6-const (TL;DR const doesn't allow rebinding [it is not about immutability]).

I agree with mcs about in the end the technical advantages are small, however for new contributors it reduces the cognitive load, because they know that variable will not change in that scope.

E.g Every time I see a let in the beginning of the file, I assume that variable can change and it can be undefined or null!

Note: See TracTickets for help on using tickets.