Created
January 23, 2017 20:41
-
-
Save solominh/42ac2dd67408f6c14d9b9ff135406ed4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // userdata.js | |
| class User { | |
| constructor(name) { | |
| this.name = name; | |
| } | |
| } | |
| export class Item { | |
| constructor(name) { | |
| this.name = name; | |
| } | |
| } | |
| export const CONST = 'Jack'; | |
| export let func = () => { }; | |
| export default User; | |
| let privateVar = 1; | |
| // Export an object | |
| export { | |
| User as default, | |
| Item, | |
| CONST, | |
| func | |
| }; | |
| // main.js | |
| import User from './userdata' // Import from export default | |
| import {CONST,func} from './userdata' // Import from export | |
| // Alias | |
| import { | |
| CONST as JACK, | |
| func as myfunc | |
| } from '.userdata' | |
| // Import from export default + export | |
| import User, {CONST,func} from './userdata' | |
| // Import all | |
| import * as UserData from './userdata' | |
| UserData.User | |
| const {CONST,func} = UserData // Destructuring object | |
| // Import library | |
| import underscore ; | |
| // React style | |
| import React, { Component, PropTypes } from 'react'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment