`for (const nKey in Object) {};` Is a perfectly va...
# suitescript
a
for (const nKey in Object) {};
Is a perfectly valid ES6 and since keys are generally static I think is a common and good practice. But but NetSuite does not like that; it does not even allow you to upload the file with that.
m
Works fine for me
message has been deleted
I think naming a variable
Object
could lead to some weird bugs down the line as it will shadow the built in Object
Personally my preference is
Object.keys(myObject).forEach(key => {})
s
those two actually have different semantics
m
@stalbert do you mean in the case of inherited properties?
s
right
m
usually with a for..in your would want a check for
hasOwnProperty
, hence my preference
s
I rarely run into cases to use any of that, unless I'm doing it once in some background utility library
a
I will have to reproduce but the code was in a module, and the error was when trying to create the script record, not uploading the file.(my bad)...
m
yeah but my eslint complains if I don't 🙂
s
I mean, I rarely write app code that needs to traverse keys of an object in a generalized fashion
often that implies code that's trying to be clever
@alien4u if you really did use the object name
Object
maybe that was the root cause of the issue?
a
@stalbert No, no object name, that was an example.
s
I figured that was the case
I haven't ran into anything ES6 related that hasn't worked - yet (also worth saying that I haven't needed to use all ES2018 features)
m
Yup I'm using ES6+ extensively and yet to find any language issues. I have run into a couple of API glitches
s
full disclosure - I've been using ES6+ stuff for many years in SuiteScript via TS, so that may play a role