I have a few JavaScript files with some jQuery code. I am including this files to the my JavaServerPages files according to needs. I am wondering how can I create object, class or something common in JavaScript, which I can use in another JavaScript files?
I have created something similar to this:
function Util() {
Util.getString = function() {
var newString = "hello";
return newString;
}
}
It takes place in my basic JavaScript file. I have included it on my basic layout JSP file. I am using it in a jQuery function in another JavaScript file in this way:
var util = new Util();
Util.getString();
It works properly. But why can I not use util.getString()
? util
is my just created object, wright?
What is the best solution to my issue?