Access object property in array of objects

前端 未结 3 1900
粉色の甜心
粉色の甜心 2020-12-03 19:35

I have this set

var data = [
    {\"outlet_name\":\"Easy Lane Supermart\",\"20130102_20130108\":\"0\"},
    {\"outlet_name\":\"Eunilaine Foodmart Kalayaan\",         


        
3条回答
  •  佛祖请我去吃肉
    2020-12-03 19:43

    $.each(data, function (i, item) {
        console.log(item.outlet_name);
    });
    

    Or without jQuery:

    for (var i=0;i

    Ok, if you want to iterate over each object you can write:

    $.each(data, function (i, item) {
        console.log("Values in object " + i + ":");
        $.each(item, function(key, value) {
            console.log(key + " = " + value);
        });
    });
    

提交回复
热议问题