You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-5Lines changed: 19 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -361,27 +361,41 @@ import `underscore`
361
361
362
362
> It is important to note that simply **importing an entire file will execute all code at the top level of that file**.
363
363
364
-
We can also use destructuring to import a list of values from a file:
364
+
Similar to Python, we have named imports:
365
365
366
366
```javascript
367
367
import { sumTwo, sumThree } from'math/addition'
368
368
```
369
369
370
-
Similar to Python, we have named imports:
370
+
We can also rename the named imports:
371
371
372
372
```javascript
373
-
import {
374
-
sumTwoasaddTwoNumbers,
373
+
import {
374
+
sumTwoasaddTwoNumbers,
375
375
sumThreeassumThreeNumbers
376
376
} from'math/addition'
377
377
```
378
378
379
-
And lastly, we can **import all the things**:
379
+
In addition, we can **import all the things** (also called namespace import):
380
380
381
381
```javascript
382
382
import*asutilfrom'math/addition'
383
383
```
384
384
385
+
Lastly, we can use destructuring to import a list of values from a file:
386
+
387
+
```javascript
388
+
import*asaddtionUtilfrom'math/addtion';
389
+
const { sumTwo, sumThree } = addtionUtil;
390
+
```
391
+
392
+
or when we are importing the default object but we want to grab some of the functions on the object:
393
+
394
+
```javascript
395
+
importReactfrom'react';
396
+
const { Component, PropTypes } = React;
397
+
```
398
+
385
399
> **Note**: Values that are exported are **bindings**, not references. Therefore, changing the binding of a variable in one module will affect the value within the exported module. Avoid changing the public interface of these exported values.
386
400
387
401
<sup>[(back to table of contents)](#table-of-contents)</sup>
0 commit comments