ES6+ javascript module export options

后端 未结 3 939
独厮守ぢ
独厮守ぢ 2020-11-27 09:32

I\'ve seen public exports of ES6 modules done in both of the following ways:

// method 1
export var getAnswer = function () { return \'forty two\'; };

// me         


        
3条回答
  •  时光取名叫无心
    2020-11-27 10:31

    1. Are both of these valid?

    No, export function () { return answer; }; is invalid, either you use default, or you add a name to that function declaration.

    1. If so, why do they both exist?

    They don't :)

    1. Are there other valid options for module exports using ES6 syntax?

    You can see a lot of valid options here: https://github.com/eslint/espree/pull/43

提交回复
热议问题