Why use import instead of require()?



Why use import instead of require() ?


We can use import to import pieces of our a module or an entire module. With require() we will be importing an entire module. So say we have a module with 15 methods, but we only need one of those methods - using import with named exports allows us to import the single method we need from the module, saving both time and memory, whereas require() will import all 15 methods (the entire module assigned to module.exports ).