Revealing Module Pattern for JavaScript
var SiteJavascript = function () {
function test() {
alert('SiteJavascript test');
}
return {
test:test
}
};
Usage:
01 reference the script.
In an MVC page all script would be in the @section Scripts section.
<script src="~/js/siteJavascript.js" asp-append-version="true"></script>
02 initialize and call the test function
var site = SiteJavascript();
site.test();