简体   繁体   中英

For each in Underscore.JS

I'm trying to loop the items inside URLs

<% _.each(jobs, function(job) { %>
    <%= job.get('error') %>
    <%= job.get('urls') %>
<% }); %>

Result of above code false

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]





{
      "error": false,
      "urls": [
        {
          "id": "1",

        },
        {
          "id": "2",

        },
        {
          "id": "3",

        }
      ]
    }

How do i loop the Id out

For people to benefit For debugging do <% console.log('text')%> It helps alot , ignore the comments above, too general , useless.

   <% _.each(pins, function(job) { %>
        <% _.each(job.get('urls'), function(item) { %>
            <% console.log(item['id'])%>
        <% }); %>
    <% }); %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM