delegate to native Object.keys in nightlies

This commit is contained in:
Mike Frawley
2010-02-17 09:26:34 -06:00
parent 7ec8d12d6c
commit c4daac089b

View File

@@ -403,7 +403,8 @@
// ------------------------- Object Functions: ------------------------------
// Retrieve the names of an object's properties.
_.keys = function(obj) {
// ECMA5 has Object.keys(obj) in webkit nightlies
_.keys = Object.keys || function(obj) {
if (_.isArray(obj)) return _.range(0, obj.length);
var keys = [];
for (var key in obj) if (hasOwnProperty.call(obj, key)) keys.push(key);