From a5454d6972063a65bfa0611a237663f19e509856 Mon Sep 17 00:00:00 2001 From: Noah Sloan Date: Tue, 8 Dec 2009 14:24:44 -0600 Subject: [PATCH] cache hasOwnProperty --- underscore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/underscore.js b/underscore.js index 81898d4af..da40afaa8 100644 --- a/underscore.js +++ b/underscore.js @@ -391,10 +391,11 @@ /* ------------------------- Object Functions: ---------------------------- */ // Retrieve the names of an object's properties. + var hasOwnProperty = Object.prototype.hasOwnProperty; _.keys = function(obj) { if(_.isArray(obj)) return _.range(0, obj.length); var keys = []; - for (var key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) keys.push(key); + for (var key in obj) if (hasOwnProperty.call(obj, key)) keys.push(key); return keys; };