It\'s considered good practice to use a self-invoking function to wrap strict mode compliant code, often called the strict mode pragma:
(function(){ \"use stri
Method 1 would fail if it's pasted in another function.
Using method 3, it is easier to export your methods to another namespace. Simply replacing window with, say, frames[0] or document is enough to attach all methods to a custom namespace.
window
frames[0]
document
I recommend method 3, for the last reason.