Lodash _.pluck怎么了? [英] What happened to Lodash _.pluck?

查看:174
本文介绍了Lodash _.pluck怎么了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经使用过Lodash _。pluck ...我喜欢采摘...

I once used Lodash _.pluck...I loved pluck...

实现Lodash no更长的支持采摘(从Lodash 4.x开始),我很难记住要使用的内容......

Realizing Lodash no longer supports pluck (as of Lodash 4.x), I'm struggling to remember what to use instead...

我去了文档,点击cmd-f,键入'pluck',但我可怜的被遗弃的朋友是甚至没有给出适当的提及......甚至没有'被'取代'......

I went to the docs, hit cmd-f, typed 'pluck', but my poor abandoned friend is not even given a proper mention...not even a 'has been replaced by'...

有人可以提醒我,我应该使用什么代替?

Can someone please remind me what I'm supposed to use instead?

推荐答案

啊哈! Lodash Changelog 说明了一切......

Ah-ha! The Lodash Changelog says it all...

已删除 _。pluck 支持 _。map with iteratee shorthand

"Removed _.pluck in favor of _.map with iteratee shorthand"

var objects = [{ 'a': 1 }, { 'a': 2 }];

// in 3.10.1
_.pluck(objects, 'a'); // → [1, 2]
_.map(objects, 'a'); // → [1, 2]

// in 4.0.0
_.map(objects, 'a'); // → [1, 2]

这篇关于Lodash _.pluck怎么了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆