We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
类似 lodash.keyBy,这里仅仅考虑第二个参数为函数的情况
// Output: { // "1": { // "id": 1, // "name": "山月" // }, // "2": { // "id": 2, // "name": "shanyue" // } // } keyBy([{ id: 1, name: '山月' }, { id: 2, name: 'shanyue' }], x => x.id)
The text was updated successfully, but these errors were encountered:
function keyBy (list, by) { return list.reduce((acc, x) => { acc[by(x)] = x return acc }, {}) }
Sorry, something went wrong.
这里其实是利用对象的键都是有序的,把类数组转成了对象
No branches or pull requests
类似 lodash.keyBy,这里仅仅考虑第二个参数为函数的情况
The text was updated successfully, but these errors were encountered: