Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
391 views
in Technique[技术] by (71.8m points)

javascript - Lodash _.pluck怎么了?(What happened to Lodash _.pluck?)

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

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

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

(意识到Lodash不再支持pluck (从Lodash 4.x开始),我很难记住要用什么代替......)

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'...

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

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

(有人可以提醒我,我应该使用什么?)

  ask by sfletche translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ah-ha!

(啊,哈!)

The Lodash Changelog says it all...

(Lodash Changelog说明了一切......)

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

(“删除_.pluck支持_.map with iteratee简写”)

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]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...