Is there a javascript / jQuery analogue of .NET Enumerable.Select?

I have an array of javascript objects, each of which contains the members "Id" and "Name". Is there any built-in way in javascript / jQuery to project this array into another array, for example one that contains only Element Names. In other words, something similar to the Enumerable.Select method in .NET.

+3
source share
2 answers

Excerpt from it:

<script>

// This evil code was sourced from http://stackoverflow.com/questions/761148/jquery-document-ready-and-document-write/761190#761190
$(function () {
    document.write = function (evil) {            
        $('body').append(evil);            
    }
});
// ...evil :p mwahahah


$(function () {

    a = ["jumps", "over", "lazy", "dog"];

    b = $.map(a, function (v) {
        return "www." + v + ".com";
    });

    $.each(b, function () {
        document.write(this + "<br/>");
    });


    i = 0;
    c = $.map(b, function (v) {
        return { v: v, i: ++i, m: i * 2 };
    });

    $.each(c, function () {
        document.write(this.v + " xxx " + this.i + ' yyy ' + this.m + "<br/>");
    });

});
</script>
+1

, oldarray Name. , . JQuery

    var oldarray;

    var newarray;

    oldarray.forEach( function(element) 
    {
        newarray.push( element.Name);
    });
0

All Articles