Try:


var layerIds=[];
for(var i=0;i<x.length;i++){
layerIds[layerIds.length]=x[i].layerId;
}