I am writing a new js file and I want to wrap my function to make sure that I am safeguarding it to collide with any other functions in other js files. The issue that I am confused about is that I am using this:
var myVariable = (function (p1, p2) {
});
because I want to be able to invoke that method later on sometime by calling the variable. The above works just fine. However you can see that myVariable
is not encapsulated. When I try to do this:
(var myVariable = function (p1, p2) {
});
that does not work. My question is how do I encapsulate that function so I can use it later?