Skip to content

Instantly share code, notes, and snippets.

@brianewing
Created April 4, 2012 10:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianewing/2300335 to your computer and use it in GitHub Desktop.
Save brianewing/2300335 to your computer and use it in GitHub Desktop.
Javascript symbol-to-proc
String.prototype.__defineGetter__('proc', function() {
var prop = this;
return function(obj) {
if(typeof obj[prop] == 'function')
return obj[prop]();
return obj[prop];
}
});
// Usage:
var people = /* ... */;
people.map('name'.proc); // ["bob", "jill", ...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment