Blog>
Snippets

Combining multiple imports from the same module

Give an example of importing multiple specific exports from a module in a single import statement.
// Assume we have a module named 'utils' with several exports
import { add, subtract, multiply } from './utils';

// Using the imported methods
const sum = add(1, 2);
const difference = subtract(3, 1);
const product = multiply(2, 2);
This code imports three named exports (add, subtract, multiply) from a module located at './utils'. These functions are then used to perform arithmetic operations.