* 通过apply修改this指向
window, 改为document
document.getElementById = function(fun) {
return function() {
return fun.apply(document, arguments);
}
}(document.getElementById);
var getId = document.getElementById;
// usage:
getId("iusername");
但是这么写 是undefined
var byId = function(fun) {
return function(id) {
fun.call(document, id);
};
}(document.getElementById);
var u = byId("iusername");
console.log(u); // undefined