In es6 I can do this:
const { findIndex, last } from 'lodash';
Can I do the same in commonjs with require?
Yes, you can use destructuring in the same way in node v6 and superior. More info here: Destructuring in Node.JS
Example:
const { findIndex, last } = require('lodash');
You can pick parts of lodash to require, there are example on the lodash docs page
e.g.
const at = require('lodash/at');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With