The answer above assumes that the data indices of the array are ordered. What if the data variable is:
var data = [ {'23':'Age'}, {'12':'Gender'}, {'3':'Name'}];
So, in alphabetical order, but with random identifiers.
One way to find this:
$.each(data, function(key, value) { var i = Object.keys(value)[0]; $("select#datas").append( $("<option />").val(i).text(value[i]) );
source share