Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On what version of javascript does NetSuite currently run SuiteScripts?

On what version of javascript does netsuite currently run SuiteScripts?

This is my understanding: SuiteScript is a NetSuite scripting API that runs on a javascript engine. Javascript has multiple versions (E.G. ES6 and ES7). Which version does this engine use? Or, maybe I should be asking "What javascript engine does SuiteScript run on?". Then I could look up which version of javascript that engine runs on?

Let me give a practical example of what I'm getting at. In javascript version ECMAScript 7, you can declare an async function, but you cannot in ECMAScript 6. Can I declare an "async function" in SuiteScript? (arbitrary example)

like image 907
Andrew Castellano Avatar asked Jan 28 '18 03:01

Andrew Castellano


2 Answers

For Server side, I believe it is ECMAScript 5 (or so it has worked that way for my purposes). So no async/await, sorry. You can use your own implementation of Promises (or use Suitescript 2.0 which includes promises). Client side depends on the browser that's running it, so you could use async if it's supported in your coworkers browsers.

The server-side Javascript runs on Rhino (not sure of the version) which is different from Node.js and plays a bit more like a browser environment with no access to window. Certain limitations are placed on the backed (no XMLHTTPRequest, instead, you have to use one of their builtin methods, etc).

like image 164
M. Pope Avatar answered Oct 14 '22 06:10

M. Pope


Just to update everyone: As of Suitescript 2.1 ES9 is supported so now you can have serverside promises and async/await.

like image 8
Adolfo Garza Avatar answered Oct 14 '22 07:10

Adolfo Garza