Created
October 17, 2018 15:10
-
-
Save vampaynani/e43f57d6eb8e1eba844d6439f60bfb92 to your computer and use it in GitHub Desktop.
Imports and exports with JS
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
/* ============================================ | |
* index.js | |
* ============================================*/ | |
import sumOperation from './operations' | |
/* ============================================ | |
* operations.js | |
* ============================================*/ | |
export default sum = (a,b) => a+b; | |
///////////////////////////////////////////// | |
/* ============================================ | |
* index.js | |
* ============================================*/ | |
import { sum, times } from './operations' | |
import * as operations from './operations' | |
operations.sum() | |
/* ============================================ | |
* operations.js | |
* ============================================*/ | |
export const sum = (a,b) => a+b; | |
export const times = (a,b) => a*b; | |
///////////////////////////////////////////// | |
/* ============================================ | |
* index.js | |
* ============================================*/ | |
import { sum, times } from './operations' | |
import operations from './operations' | |
operations.sum() | |
/* ============================================ | |
* operations.js | |
* ============================================*/ | |
const sum = (a,b) => a+b; | |
const times = (a,b) => a*b; | |
export default { sum, times }; | |
///////////////////////////////////////////// | |
/* ============================================ | |
* index.js | |
* ============================================*/ | |
const { sum, times } = require('./operations') | |
const operations = require('./operations') | |
operations.sum() | |
/* ============================================ | |
* operations.js | |
* ============================================*/ | |
const sum = (a,b) => a+b; | |
const times = (a,b) => a*b; | |
module.exports = { sum, times }; | |
///////////////////////////////////////////// | |
/* ============================================ | |
* index.js | |
* ============================================*/ | |
const { sum, times } = require('./operations') | |
const operations = require('./operations') | |
operations.sum() | |
/* ============================================ | |
* operations.js | |
* ============================================*/ | |
exports.sum = (a,b) => a+b; | |
exports.times = (a,b) => a*b; | |
///////////////////////////////////////////// | |
/* ============================================ | |
* index.js | |
* ============================================*/ | |
const { sum, times } = require('./operations') | |
const operations = require('./operations') | |
operations.sum() | |
/* ============================================ | |
* operations.js | |
* ============================================*/ | |
const operations = { | |
sum: (a,b) => a+b, | |
times: (a,b) => a*b | |
} | |
module.exports = operations; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment