javascript - get array of attribute from an array of objects -


say have array of objects in javascript as

var array=[{id:1,message:"hello",time:"00-00-0000"},{id:2,message:"sup",time:"00-00-0000"},...]; 

what best way array containing message attribute. i.e.

var messages=["hello","sup",...]; 

the "best" way be:

var messages = array.map(function(x) {return x.message;}); 

the most compatible way:

for(var messages=[],i=0,l=array.length; i<l; i++) messages[i]=array[i].message; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -