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
@@ -364,27 +364,41 @@ import `underscore`
364
364
365
365
> It is important to note that simply **importing an entire file will execute all code at the top level of that file**.
366
366
367
-
We can also use destructuring to import a list of values from a file:
367
+
Similar to Python, we have named imports:
368
368
369
369
```javascript
370
370
import { sumTwo, sumThree } from'math/addition'
371
371
```
372
372
373
-
Similar to Python, we have named imports:
373
+
We can also rename the named imports:
374
374
375
375
```javascript
376
-
import {
377
-
sumTwoasaddTwoNumbers,
376
+
import {
377
+
sumTwoasaddTwoNumbers,
378
378
sumThreeassumThreeNumbers
379
379
} from'math/addition'
380
380
```
381
381
382
-
And lastly, we can **import all the things**:
382
+
In addition, we can **import all the things** (also called namespace import):
383
383
384
384
```javascript
385
385
import*asutilfrom'math/addition'
386
386
```
387
387
388
+
Lastly, we can use destructuring to import a list of values from a file:
389
+
390
+
```javascript
391
+
import*asaddtionUtilfrom'math/addtion';
392
+
const { sumTwo, sumThree } = addtionUtil;
393
+
```
394
+
395
+
or when we are importing the default object but we want to grab some of the functions on the object:
396
+
397
+
```javascript
398
+
importReactfrom'react';
399
+
const { Component, PropTypes } = React;
400
+
```
401
+
388
402
> **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.
389
403
390
404
<sup>[(back to table of contents)](#table-of-contents)</sup>
0 commit comments