Copy // addition.js
function addTwo(a,b){
return a + b;
}
export { addTwo };
// app.js
import { addTwo } from './addition';
console.log(addTwo(2, 4)); // 6
Copy // addition.js
function addTwo(a,b){
return a + b;
}
function addThree(a,b,c){
return a + b + c;
}
export { addTwo, addThree };
// app.js
import { addTwo, addThree } from './addition';
console.log(addTwo(2, 4)); // 6
console.log(addThree(2, 4, 5)); // 11
Copy // addition.js
export function addTwo(a,b){
return a + b;
}
export function addThree(a,b,c){
return a + b + c;
}
Copy // addition.js
function addTwo(a,b){
return a + b;
}
function addThree(a,b,c){
return a + b + c;
}
export { addTwo, addThree };
// app.js
import { addTwo as addTwoNumber, addThree } from './addition';
console.log(addTwoNumber(6, 4)); // 10
console.log(addThree(2, 4, 5)); // 11
Copy // app.js
import * as adder from './addition';
console.log(adder.addTwoNumber(6, 4)); // 10
console.log(adder.addThree(2, 4, 5)); // 11
Copy // users.js
export var users = [
{name: "hemant", age: 20, location: "hyderabad"},
{name: "vinay", age: 80, location: "hyderabad"},
{name: "paa", age: 90, location: "hyderabad"},
{name: "varun", age: 44, location: "hyderabad"}
];
// app.js
import * as _ from "lodash"; // npm i lodash -S
import {users } from './users';
console.log(_.where(users, {age: 20}));
Copy // greet.js
export default function greet(){
}
// app.js
import greet from './greet';
// OR
import myGreet from './greet'; // any name can be used for default export
greet();