export default vs export {} code example

Example 1: export default

/*
Since export default is used to declare a fallback value for a module or 
file, you can only have one value be a default export in each module or 
file. Additionally, you cannot use export default with var, let, or const.
*/

// named function
export default function add(x, y) {
  return x + y;
}

// anonymous function
export default function(x, y) {
  return x + y;
}

Example 2: javascript export default

export default const array = [1, 2, 3];
export default let array = [1, 2, 3];
export default var array = [1, 2, 3];
export default const variable = 'value';
export default let variable = 'value';
export default var variable = 'value';
export default const variable;
export default let variable;
export default var variable;
export default function functionName () {
  // ...
}
export default class ClassName {
  // ...
}
// Before you use export default: You can't have 2 or more export default's.