Skip to content

Instantly share code, notes, and snippets.

@vampaynani
Created October 17, 2018 15:10
Show Gist options
  • Save vampaynani/e43f57d6eb8e1eba844d6439f60bfb92 to your computer and use it in GitHub Desktop.
Save vampaynani/e43f57d6eb8e1eba844d6439f60bfb92 to your computer and use it in GitHub Desktop.
Imports and exports with JS
/* ============================================
* 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