Jump to content

Search the Community

Showing results for tags 'promise'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. This is a question I got asked in an interview. I know the array would just return zeros since this is asynchronous, but why does this happen, and how can you fix it so that the results array inserts the appropriate data? Question: Suppose findData is a function that takes a query object and returns a promise for the result of the query. Suppose also that someRandomArrayOfQueries is an array of query objects. Explain what would be printed by the following code and why: function runMultipleQueries(queries) { var results = []; queries.forEach(doQuery); return results; function doQuery(query) { findData(query) .then(results.push.bind(results)); } }function log(value) { console.log(value);}runMultipleQueries(someRandomArrayOfQueries).forEach(log);
×
×
  • Create New...