Skip to content

Instantly share code, notes, and snippets.

@arian
Created July 28, 2010 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arian/494021 to your computer and use it in GitHub Desktop.
Save arian/494021 to your computer and use it in GitHub Desktop.
Simple snippet that makes it easy to use namespaced.object.like.this
// Simple snippet that makes it easy to use namespaced.object.like.this
Function.use = function(object, fn, bind, args){
var objects = Array.flatten([object]);
fn.apply(bind, args ? objects.concat(args) : objects);
};
// Example of Function.use
Function.use([Object.keys, Object.values], function(keys, values){
console.log(arguments);
console.log(''+this);
var obj = {
foo: 'bla',
bar: 'temp',
temp: 'foo'
};
console.log(keys(obj));
console.log(values(obj));
}, 'bar', ['foo', 'temp']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment