Created
July 28, 2010 10:47
-
-
Save arian/494021 to your computer and use it in GitHub Desktop.
Simple snippet that makes it easy to use namespaced.object.like.this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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