Message from JavaScript discussions

August 2017

— 

for (object of result[0]) {
for (key in object) {
console.log(object[key][0].id);
}
}

— 

Var a = JSON.parse('[{"2017-07-28":[{"id":1,"produk_id":1,"nama_id":1,"jumlah_user_id":1,"harga":"50000","tanggal_efektif":"2017-07-28"}]}]');

for(x in a)
for(y in a[x])
for(z in a[x][y])
console.log(a[x][y][z]['id']);

— Tested :3

— Language:

js


Source:
var a = JSON.parse('[{"2017-07-28":[{"id":1,"produk_id":1,"nama_id":1,"jumlah_user_id":1,"harga":"50000","tanggal_efektif":"2017-07-28"}]}]');

for(x in a)
for(y in a[x])
for(z in a[x][y])
console.log(a[x][y][z]['id']);


Result:
1

Message permanent page

— 🤔 not work

— And i need to make a variable of that? how to variable a json that called in ajax?

— 🤔 write one before, but doesn't work

— You shouldn't use for..in for arrays

— Wow 🌚

— 😅 what was wrong?

— AJAX always response with a string, you must use JSON.parse to get arrays

— Or $.getJSON