0

I've just started out with javascript and came across this line in a file called global.js There is only one line in the file. I'm not sure what does App do. Any ideas?

Filename: globals.js

//The Application 
App = {};
3
  • You have a file with one line of code somewhere and you're expecting us to know what it does ? Commented Dec 27, 2013 at 14:47
  • 1
    It creates an empty object. Thats it. Commented Dec 27, 2013 at 14:49
  • @adeneo - yes. I'm not looking for a long blown out answer. I'm just not sure on its usage. Commented Dec 27, 2013 at 14:53

5 Answers 5

3

it creates an object with a name of App... that's all it does.

Sign up to request clarification or add additional context in comments.

Comments

1

I would assume that the idea behind the global.js file in your case is to include the file in your base html/template so that the variables in there can be accessed from anywhere in the app.

In some of our projects, we've had global files like this containing references to collections and "setting" variables, which is quite handy :)

1 Comment

Thanks @jesuli! I'll have to look into the other pages.
0

It is creating an object named App in the global namespace. App has no functions or attributes (yet).

Comments

0

It (implicitly) declares a variable called App in a "global" context and assigns an empty object as its value. Assuming this is used on a web page somewhere, it's the same as declaring window.App = {}.

How this affects the rest of your application, we won't know until you post more relevant code.

1 Comment

Thanks pete for the answer!
0

This script just instantiate this empty Object. Probably, others scripts that ran along with this uses that object and depends that it is created there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.