Skip to content

Instantly share code, notes, and snippets.

@teramako
Created May 16, 2011 09:00
Show Gist options
  • Save teramako/974120 to your computer and use it in GitHub Desktop.
Save teramako/974120 to your computer and use it in GitHub Desktop.
どこかで見かけたProxyのサンプル
var $ = Proxy.ceate({
get: function (_, name) {
return function () {
var args = Array.prototype.slice.call(arguments);
var func = function (o) {
return o[name].apply(o, args);
};
return func;
};
}
});
// --------------------------------------------
// Example
// --------------------------------------------
/*
["a","b","c"].map($.toUpperCase()); // ["A","B","C"]
same as
["a","b","c"].map(function(o){ return o.toUpperCase(); })
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment