0

I have a function declared

x.funstuff = function(){

}

When I want to call it within a file I simply declare

x = {};

However when I call it from another file I get issues. Even after I use x = {};

in that seperate file.

How does one call this function from another file?

2
  • What is the problem? What happens? Commented Mar 11, 2014 at 19:46
  • Okay nevermind. The issue seems more complicated. This is actually a dumbed down version of my code however I just tried running this code itself and it works. I am going to modify my question Commented Mar 11, 2014 at 19:47

1 Answer 1

1

If you are doing it in the order specified then you are overwriting your x variable with a new object.

x.funstuff = function() {};

means that x = { funstuff: function() {} };

then x = {}; replaces it

If you are trying to call the function do it as:

x.funstuff();
Sign up to request clarification or add additional context in comments.

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.