Search

1/26/2010

Branching


var xhrRequest = (function () {
if (ie) {
return function (method, url) { // Use ActiveX control.
};
} else {
return function (method, url) { // Use XMLHttpRequest.
};
}
})();

This is useful, because the branching logic is executed only once, at script load time. If done instead in the traditional way, the branching logic would be execute each time the function is called.

沒有留言: