Unrelated question, the code on this page <https:/...
# suitescript
m
Unrelated question, the code on this page https://system.netsuite.com/app/help/helpcenter.nl?fid=section_157072957990.html have
const
and
let
, I thought NS doesn't accept anything after ES5
d
This is SuiteScript 2.1, it supports ES.Next
m
I didn't know that, is that new?
d
It's been for a while, couple years I believe
m
I am living under a rock. Thanks very much ❤️
d
Though I still don't understand why they declare
Copy code
let sublist
I would use const here as well
m
I have no idea. Maybe the developer didn't feel it like a constant because it calls some functions 🙂
m
I've seen some developers use
const
for things that cannot change and
let
for things that can change. The distinction being that we can change something without reassigning the variable which
const
prevents. Technically I can use
const
to create an empty array/object and still add elements/properties. This may not be in the spirit of
const
in the minds of some.
👍 3
s
Certain linting rules will complain if you use
let
for a variable that is never re-assigned, even if that variable is an object or array that you modify later. Our company follows those rules, so we use
const
whenever possible, even on mutable objects and arrays.