Javascript Equivalent to C# LINQ Select

前端 未结 12 1525
孤街浪徒
孤街浪徒 2020-12-02 06:33

Following this question here :

Using the checked binding in knockout with a list of checkboxes checks all the checkboxes

I\'ve c

12条回答
  •  死守一世寂寞
    2020-12-02 07:05

    The most similar C# Select analogue would be a map function. Just use:

    var ids = selectedFruits.map(fruit => fruit.id);
    

    to select all ids from selectedFruits array.

    It doesn't require any external dependencies, just pure JavaScript. You can find map documentation here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

提交回复
热议问题