I have a JSON object -
rows = [{name:"testname1" , age:"25"}, {name:"testname2" , age:"26"}]
I would like to extract the name information and put it into a variable like this.
name = "testname1, testname2";
var name = rows.map(function(r){
return r.name
}).join(', ');
The above code will store the string testname1, testname2
into the name
variable.
For more information on the .map
function please see MDN .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.