Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6838877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:39:01+00:00 2026-05-26T23:39:01+00:00

This is the most irritating problem I have ever faced: var appslst = [];

  • 0

This is the most irritating problem I have ever faced:

var appslst = [];
function f1()
{
    chrome.management.getAll(function(lst)
    {
    appslst = lst;
    });
}

function f2() // this function isn't working!!
{
    var l = appslst.length;
    var ind = 0;
    while(ind < l)
    {
        document.getElementById("here").value = document.getElementById("here").value.concat(String(ind), ". ", appslst[ind].name, "\n");
        ind += 1;
    }
}

function f3()
{
     f1();
     f2();
}

I believe that appslst – as it’s a global variable – should be seen in both functions f1() and f2(), but the above code isn’t working and I have no idea why.

Also, I have tried the following code (and it’s working) :

var appslst = [];
function f1()
{
    chrome.management.getAll(function(lst)
    {
        appslst = lst;
        var l = appslst.length;
        var ind = 0;
        while(ind < l)
        {
            document.getElementById("here").value = document.getElementById("here").value.concat(String(ind), ". ", appslst[ind].name, "\n");
            ind += 1;
        }
    });
}

Some more details. I’m learning how to build extension for Google Chrome.
I have download the sample: http://code.google.com/chrome/extensions/examples/extensions/app_launcher.zip from this link: http://code.google.com/chrome/extensions/samples.html. I had a look over the code and found the same code I wrote, except that it’s working!

Here’s the part I’m talking about:

function onLoad()
{
  chrome.management.getAll(function(info)
  {
    var appCount = 0;
    for (var i = 0; i < info.length; i++) {
      if (info[i].isApp) {
        appCount++;
      }
    }
    if (appCount == 0) {
      $("search").style.display = "none";
      $("appstore_link").style.display = "";
      return;
    }
    completeList = info.sort(compareByName);
    onSearchInput();
  });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:39:02+00:00Added an answer on May 26, 2026 at 11:39 pm

    chrome.management.getAll is asynchronous – hence you need to pass a function that is executed only when Chrome is done executing getAll.

    This means that f1(); f2(); will go like this:

    • f1 is called
    • getAll is called (that’s what f1 is doing)
    • f2 is called
    • iterating over appslst (that’s what f2 is doing)
    • (some time in between)
    • getAll is done; the function passed to it is called
    • appslst is filled with data from getAll (that’s what the passed function is doing)

    In other words, appslst is still empty at the time f2 is called. So you need to suspend f2() as well:

    chrome.management.getAll(function(lst){
        appslst = lst;
        f2(); // only run when getAll is done and appslst is filled
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably the most classic database problem. I have an E-commerce software solution
This is possibly the most irritating thing ever. I've spent a long long time
I have a very irritating problem. I'm working with a list of documents, but
this is most likely a simple answer that i have overlooked.. I am trying
I have this situation that is really irritating me now. At random times with
This most be the second most simple rollover effect, still I don't find any
I am having this most annoying issue when I try to rebuild my solution
This is most likely not an easy one but here is the situation: I
I know this is most-likely a simple question but when you restore a database
This is actually a non-critical question, but I get this warning most of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.