From 9a27b1b083f8651e95f3622bfe5a338f36f7511a Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Mon, 19 Mar 2012 15:07:33 -0400 Subject: [PATCH] Clarify documentation for _.result. --- index.html | 3 ++- underscore.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index f2a00cae3..7ebdc3f6e 100644 --- a/index.html +++ b/index.html @@ -1313,7 +1313,8 @@ _.escape('Curly, Larry & Moe');

result_.result(object, property)
- 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.

 var object = {cheese: 'crumpets', stuff: function(){ return 'nonsense'; }};
diff --git a/underscore.js b/underscore.js
index 6c9512594..429a9b142 100644
--- a/underscore.js
+++ b/underscore.js
@@ -873,7 +873,8 @@
     return (''+string).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
   };
 
-  // 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];