mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
maintain a single reference to the Object.prototype
This commit is contained in:
@@ -30,6 +30,9 @@
|
|||||||
// Export the Underscore object for CommonJS.
|
// Export the Underscore object for CommonJS.
|
||||||
if (typeof exports !== 'undefined') exports._ = _;
|
if (typeof exports !== 'undefined') exports._ = _;
|
||||||
|
|
||||||
|
// Maintain a reference to the Object prototype for quick access.
|
||||||
|
var oproto = Object.prototype;
|
||||||
|
|
||||||
// Current version.
|
// Current version.
|
||||||
_.VERSION = '0.4.6';
|
_.VERSION = '0.4.6';
|
||||||
|
|
||||||
@@ -392,7 +395,7 @@
|
|||||||
_.keys = function(obj) {
|
_.keys = function(obj) {
|
||||||
if(_.isArray(obj)) return _.range(0, obj.length);
|
if(_.isArray(obj)) return _.range(0, obj.length);
|
||||||
var keys = [];
|
var keys = [];
|
||||||
for (var key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) keys.push(key);
|
for (var key in obj) if (oproto.hasOwnProperty.call(obj, key)) keys.push(key);
|
||||||
return keys;
|
return keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -453,22 +456,22 @@
|
|||||||
|
|
||||||
// Is a given value a real Array?
|
// Is a given value a real Array?
|
||||||
_.isArray = function(obj) {
|
_.isArray = function(obj) {
|
||||||
return Object.prototype.toString.call(obj) == '[object Array]';
|
return oproto.toString.call(obj) == '[object Array]';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Is a given value a Function?
|
// Is a given value a Function?
|
||||||
_.isFunction = function(obj) {
|
_.isFunction = function(obj) {
|
||||||
return Object.prototype.toString.call(obj) == '[object Function]';
|
return oproto.toString.call(obj) == '[object Function]';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Is a given value a String?
|
// Is a given value a String?
|
||||||
_.isString = function(obj) {
|
_.isString = function(obj) {
|
||||||
return Object.prototype.toString.call(obj) == '[object String]';
|
return oproto.toString.call(obj) == '[object String]';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Is a given value a Number?
|
// Is a given value a Number?
|
||||||
_.isNumber = function(obj) {
|
_.isNumber = function(obj) {
|
||||||
return Object.prototype.toString.call(obj) == '[object Number]';
|
return oproto.toString.call(obj) == '[object Number]';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Is a given variable undefined?
|
// Is a given variable undefined?
|
||||||
|
|||||||
Reference in New Issue
Block a user