A widget is written in WEMScript for hooking it into the rest of the WEM functionality. The intended functionality is typically written in JavaScript to run in the browser.
JavaScript version ECMAScript ES5 is supported, that version is supported by all browsers. ES6 (ECMAScript2015) and newer versions are not (yet) supported by all browsers (particularly IE), so please use JavaScript syntax from ES5.