Reputation:
Let's say I have a variable which gets a request from a database, the request is going to be different every time the function is being called, but within one run of the function, that variable is not going to reassigned. Should I use LET or CONST please? It's quite confusing
async setSetting(guildID, settingName, value) {
let settingToFind = { guildID: guildID, setting: settingName };
/* Some code but settingToFind is not reassigned within the function... */
}
Here is an other example of where I'm not sure if I should use let or const (for settingToFind)
Upvotes: 2
Views: 191
Reputation: 748
You should use const
! This will remind other devs or your self in the future to not reassign this var or at least to think about it. If you want to allow to change it later on you could use let
, but it's common to put as strict as possible in first palce.
Upvotes: 1
Reputation: 4651
You've answered your own question:
but within one run of the function, that variable is not going to reassigned
You should use const
Upvotes: 1