Helps depending on the window object
It is useful in UMD compatible window-manipulating jQuery plugins.
Usage with curl.js
Your AMD module should depend on AMD window:
// Uses AMD or browser globals to create a jQuery plugin.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'amd-window'], factory);
} else {
// Browser globals
factory(jQuery, window);
}
}(function ($, window, undefined) {
...
}));
You can read about it in this SO question
window = {
num: 5,
str: 'text'
}
if (typeof window.num === 'undefined') {
console.log('Yes, you cannot shadow the windows object');
}