-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImport_a_Default_Export.js
More file actions
30 lines (23 loc) · 879 Bytes
/
Import_a_Default_Export.js
File metadata and controls
30 lines (23 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
Import a Default Export
In the last challenge, you learned about export default
and its uses. To import a default export, you need to
use a different import syntax.
In the following example, add is the default export of
the math_functions.js file. Here is how to import it:
import add from "./math_functions.js";
The syntax differs in one key place
The imported value, add, is not surrounded by curly
braces ({}). add here is simply a variable name for
whatever the default export of the math_functions.js
file is. You can use any name here when importing a
default.
EXERCISE
In the following code, import the default export from
the math_functions.js file, found in the same directory
as this file. Give the import the name subtract.
*/
// This code does not run on node.js
import subtract from './math_functions.js';
// Only change code above this line
subtract(7,4);