[javascript] Javascript ES6 export const vs export let

Let's say I have a variable that I want to export. What's the difference between

export const a = 1;

vs

export let a = 1;

I understand the difference between const and let, but when you export them, what are the differences?

This question is related to javascript ecmascript-6 es6-modules

The answer is


I think that once you've imported it, the behaviour is the same (in the place your variable will be used outside source file).

The only difference would be if you try to reassign it before the end of this very file.


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to ecmascript-6

"Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6 where is create-react-app webpack config and files? Can (a== 1 && a ==2 && a==3) ever evaluate to true? How do I fix "Expected to return a value at the end of arrow function" warning? Enums in Javascript with ES6 Home does not contain an export named Home How to scroll to an element? How to update nested state properties in React eslint: error Parsing error: The keyword 'const' is reserved Node.js ES6 classes with require

Examples related to es6-modules

How can I use an ES6 import in Node.js? Using import fs from 'fs' ES6 modules in the browser: Uncaught SyntaxError: Unexpected token import What is difference between Axios and Fetch? How can I alias a default import in JavaScript? `export const` vs. `export default` in ES6 Javascript ES6 export const vs export let Is it possible to import modules from all files in a directory, using a wildcard?