SuiteScript 2.1 Limitations
Created: October 14, 2020
After a couple of SuiteScript 2.1 emails, some helpful readers have pointed out some limitations and asked some questions. While the addition of new and powerful syntax is excellent and very much worth your time to explore, there are limitations to the support NetSuite offers.
First, according to the SuiteScript 2.1 Help page, NetSuite supports JavaScript up to version ES2019. Anything after that will not (yet) be supported in server-side JavaScript.
Second, Client Scripts do not support the version 2.1 tag. The validator will complain if you upload a Client Script source file tagged as 2.1. That said, because most browsers support the latest JavaScript syntax, you can still take advantage of the latest syntax and "work around" NetSuite's validation by tagging your Client Script as 2.x instead.
Reader Anon E Moose
points out that the Debugger does not support 2.1 (shared
with permission, name obscured by request) :
I'm surprised that you are promoting 2.1 emails. I believe that NS still has not exposed 2.1 to the debugger that makes unusable from my point of view.
Great point! If you are an avid user of NetSuite's debugger environment, then 2.1 will not be viable for you. I have never been a Debugger developer myself, but if you are, be aware of this limitation.
Reader Clay Roper points out a bit more nuance:
Quick question re optional chaining - are you able to get this to work in server SS2.1? My understanding is that Graal VM runs ES2019, so this (and features like nullish coalescing) aren't available there just yet.
Quick note: GraalVM is the engine NetSuite uses to run SuiteScript 2.1 (as opposed to SuiteScript 1.0 and 2.0 which run on the Rhino engine).
Yet another great point disguised as a question. According to the SuiteScript 2.1 Help page, Clay is correct that NetSuite only supports up to ES2019, which does not include Optional Chaining, Nullish Coalescing, and some other very cool features. That said, you can still take advantage of these in Client Scripts (the previous caveat still withstanding) because nearly all major browsers support a much newer standard than does NetSuite's server side.
Thanks for keeping me in line, everyone!