Merge pull request #514 from braddunbar/result-docs

Clarify documentation for _.result.
This commit is contained in:
Jeremy Ashkenas
2012-03-19 12:13:42 -07:00
2 changed files with 4 additions and 2 deletions

View File

@@ -1313,7 +1313,8 @@ _.escape('Curly, Larry & Moe');
<p id="result">
<b class="header">result</b><code>_.result(object, property)</code>
<br />
Returns a value from an object as a property or as a function.
If the value of the named property is a function then invoke it.
Otherwise, return its value.
</p>
<pre>
var object = {cheese: 'crumpets', stuff: function(){ return 'nonsense'; }};

View File

@@ -873,7 +873,8 @@
return (''+string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
};
// Get a value from an object as a property or as a function.
// If the value of the named property is a function then invoke it.
// Otherwise, return its value.
_.result = function(object, property) {
if (object == null) return null;
var value = object[property];