Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

get all id from array of objects javascript

function getFields(input, field) {
    var output = [];
    for (var i=0; i < input.length ; ++i)
        output.push(input[i][field]);
    return output;
}

var result = getFields(objArray, "foo"); // returns [ 1, 3, 5 ]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #id #array #objects #javascript
ADD COMMENT
Topic
Name
3+9 =