const _ = require('lodash'); const numbers = [1, 2, 3, 4, 5]; const doubledNumbers = _.map(numbers, (num) => num * 2); console.log(doubledNumbers); // Output: [2, 4, 6, 8, 10]
const _ = require('lodash'); const users = [ { id: 1, name: 'John' }, { id: 2, name: 'Jane' }, { id: 3, name: 'Michael' }, ]; const userIds = _.map(users, 'id'); console.log(userIds); // Output: [1, 2, 3]In this example, the `map()` function is used to extract the `id` property from each object in the `users` array. The second argument passed to the `map()` function is a string `'id'`, which tells the function to extract the `id` property from each object. The output will be a new array `[1, 2, 3]`. Determined Package Library: Lodash.