0

Not sure what it means when we include function within curly brackets. Can you tell the difference between the following two lines?

import {sportsPage} from 'sports-page';

import sportsPage from 'sports-page';
Sterling Archer
  • 22,070
  • 18
  • 81
  • 118
  • 1
    Isn't this just normal JS `import` semantics? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import – Dave Newton Apr 07 '16 at 19:06
  • @all why did you guys mark it negative...I didn't know that's the reason I asked –  Apr 07 '16 at 19:25
  • I can't answer for whoever downvoted, but probably because the answer is pure JS, and relatively easy to find out. – Dave Newton Apr 07 '16 at 19:27
  • @DaveNewton I am beginner very new to js and programming :( –  Apr 07 '16 at 19:32

1 Answers1

1

Here's a good read on ES6 modules: https://24ways.org/2014/javascript-modules-the-es6-way/

The difference between those two, is that brackets {} are used when you are not exporting a default module. You can't rename them!

Without brackets, the exported function, variable, etc needs to be a default. You can name myFunction whatever you like.

export default myFunction;

...

import somethingsomethingDangerZone from "myfunction.js";
Sterling Archer
  • 22,070
  • 18
  • 81
  • 118
  • thanks for the explanation...really nice article https://24ways.org/2014/javascript-modules-the-es6-way/ –  Apr 07 '16 at 22:16