1

I have two java script files one defines an object

function Alliance(teamOneNumber,teamTwoNumber)
{
     /*implementation*/
}

And I use it in another file like this

function compute(r1,r2)
{
     var red = new Alliance(r1,r2);
     /*implementation*/
}

How do I get JsHint to recognize that Alliance is defined in another file. Instead of warning me that Alliance is undefined.

1 Answer 1

1

You can use the global directive (or look up how to configure "globals" in whatever plugin you're using):

/*global Alliance: false */
function compute(r1,r2)
{
     var red = new Alliance(r1,r2);
     /*implementation*/
}

The false indicates that Alliance cannot be assigned to in this scope. If you do need the ability to assign to it you can use true instead.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.