Binding window objects

I have this script http://pastebin.com/PY922MyL
How can i bind the slideSwitch method to window such that i can call it with window.slideSwitch() ?

Not sure if I understand, but have you tried:

window.onload = functionname

i’m not trying to run it onload.

i’m trying to create the method in the window object.
so i should be able to run the method by just typing slideSwitch() in the console.
but i wan it enclosed in the self executing function and only expose the method to the window object at the end.

edit: hmm…i’d found the anwser. http://pastebin.com/3CMsCkSK

With your code here:


(function($, w) {
    w.slideSwitch = ...
})(jQuery,window);

What benefit does that provide over and above the following standard jQuery pattern?


jQuery(function ($) {
    window.slideSwitch = ...
});