Created
October 30, 2013 15:28
-
-
Save hanbzu/7234563 to your computer and use it in GitHub Desktop.
JavaScript: Prop: Property of. Thanks to Christian Johansen.
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
// If I define the 'prop' function | |
function prop(name) { | |
return function (object) { | |
return object[name]; | |
}; | |
} | |
// Instead of this | |
var str = "Mentioned by " + tweeps.map(function (t) { | |
return t.name; | |
}).join(", "); | |
// I can do this | |
var str = "Mentioned by " + tweeps.map(prop("name")).join(", "); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment