是否有与 .NET 的 Enumerable.Select 相对应的 javascript/jQuery?
我有一个 javascript 对象数组,每个对象都包含成员“Id”和“Name”。 javascript/jQuery 中是否有任何内置方法可以将此数组投影到另一个数组中,例如仅包含元素名称的数组。换句话说,类似于 .NET 中的 Enumerable.Select 方法。
I have an array of javascript objects, each containing the members "Id" and "Name". Are there any built-in way in javascript/jQuery to project this array into another array, for example one that contains only the Names of the elements. In other words, something similar to the Enumerable.Select method in .NET.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Codeplex 上有一个 LINQ for JavaScript 项目:http://linqjs.codeplex.com/
这里描述了另一种方法: http://www.ienablemuch.com/2011 /05/jquerys-linqs-select.html
摘录如下:
There's a LINQ for JavaScript project on Codeplex: http://linqjs.codeplex.com/
Another method is described here: http://www.ienablemuch.com/2011/05/jquerys-linqs-select.html
An excerpt from it is:
假设您的 oldarray 包含具有 Name 属性的对象。新数组应仅包含旧数组中对象名称的字符串。使用 Jquery 来完成如此简单的任务可能有点大材小用
Assuming your oldarray contains objects that have a Name attribute. The new array should contain just strings that are the names of the objects in the old array. Using Jquery for such a simple task might be an overkill