The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Function Accessing Variable From Another Function?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #245051

    Hey guys and girls

    I’m working my way through a Javascript book and there’s a section in there that I’m not sure about. Below is a pen of the code from that section.

    It looks like a function is accessing a local variable from another function.

    The var in question is obj. I think the reason the code works is because the uk() and eu() functions are being called within the init() function? It doesn’t matter that the function is created outside of init()?

    Is my understanding of that correct?

    Many thanks to anyone who helps


    your code is working. I don’t see any errors.

    it’s true, obj is declared inside a private function and is not accessible from the other functions, but you are passing it as parameter so it’s fine.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.