Arrow Function in Object Literal [duplicate]

Note that the Babel translation is assuming strict mode, but your result with window indicates you’re running your code in loose mode. If you tell Babel to assume loose mode, its transpilation is different: var _this = this; // ** var arrowObject = { name: ‘arrowObject’, printName: function printName() { console.log(_this); // ** } }; … Read more

Getting Unexpected Token Export

Updated for 2022 You are using ES6 Module syntax. This means your environment (e.g. node v14.13.0 or newer) must support ESM (Ecmascript Module Syntax). NodeJS since v14.13.0 supports EcmaScript Module Syntax but it must be enabled by adding the property “type”:”module” to package.json. NodeJS versions prior to v14.13.0 uses CommonJS Module syntax by default (module.exports), … Read more