How to access objects in an external js file from another external js file
12:51 05 Sep 2016

Hello fellow programmers,

I am wondering today how to access objects from another external js file. I'm using this as a way to organize my code throughout multiple js files. Here's an example of what I'm trying to say.

Imagine this as the code from an external js file:

$(function () {

  function Person() {
    this.name = "Bob";
  }

})

And I want to access that object in another js file:

$(function () {

  var person = new Person;
  alert(person.name);

})

Is there a way to do something like that? How would I need to position the html?

javascript object external-js