Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Formatting. The link to the updated version of underscore.js linked to the master branch, which could misalign the line anchors in the URL in future versions
Source Link
Gust van de Wal
  • 5.3k
  • 1
  • 27
  • 52

The official underscore.js uses this checkprovides the following method to find out if something is really an object:

// Is a given variable an object?
_.isObject = function(obj) {
  return obj === Object(obj);
};

UPDATE

The updated underscore.js library is now using the following, becauseBecause of a previous bug in V8 and minor micro speed optimization., the method looks as follows since underscore.js 1.7.0 (August 2014):

// Is a given variable an object?
_.isObject = function(obj) {
  var type = typeof obj;
  return type === 'function' || type === 'object' && !!obj;
};

The official underscore.js uses this check to find out if something is really an object

// Is a given variable an object?
_.isObject = function(obj) {
  return obj === Object(obj);
};

UPDATE

The updated underscore.js library is now using the following, because of a previous bug in V8 and minor micro speed optimization.

// Is a given variable an object?
_.isObject = function(obj) {
  var type = typeof obj;
  return type === 'function' || type === 'object' && !!obj;
};

underscore.js provides the following method to find out if something is really an object:

_.isObject = function(obj) {
  return obj === Object(obj);
};

UPDATE

Because of a previous bug in V8 and minor micro speed optimization, the method looks as follows since underscore.js 1.7.0 (August 2014):

_.isObject = function(obj) {
  var type = typeof obj;
  return type === 'function' || type === 'object' && !!obj;
};
quote the lines of code precisely, instead of own version
Source Link
Daan
  • 8k
  • 5
  • 47
  • 54

The official underscore.js uses this check to find out if something is really an object

// Is a given variable an object?
_.isObject = function(obj) {
  return obj === Object(obj);
};

UPDATE

The updated underscore.js library is now using the following, because of a previous bug in V8 and minor micro speed optimization.

// Is a given variable an object?
_.isObject = function(obj) {
  returnvar type = typeof objobj;
  return type === 'function' || (typeof objtype === 'object' && !!obj);obj;
};

The official underscore.js uses this check to find out if something is really an object

// Is a given variable an object?
_.isObject = function(obj) {
  return obj === Object(obj);
};

UPDATE

The updated underscore.js library is now using the following, because of a previous bug in V8 and minor micro speed optimization.

// Is a given variable an object?
_.isObject = function(obj) {
  return typeof obj === 'function' || (typeof obj === 'object' && !!obj);
};

The official underscore.js uses this check to find out if something is really an object

// Is a given variable an object?
_.isObject = function(obj) {
  return obj === Object(obj);
};

UPDATE

The updated underscore.js library is now using the following, because of a previous bug in V8 and minor micro speed optimization.

// Is a given variable an object?
_.isObject = function(obj) {
  var type = typeof obj;
  return type === 'function' || type === 'object' && !!obj;
};
updated link + added updated way in underscore.js to determine object
Source Link
Daan
  • 8k
  • 5
  • 47
  • 54

The official underscore.jsunderscore.js uses this check to find out if something is really an object

// Is a given variable an object?
_.isObject = function(obj) {
  return obj === Object(obj);
};

UPDATE

The updated underscore.js library is now using the following, because of a previous bug in V8 and minor micro speed optimization.

// Is a given variable an object?
_.isObject = function(obj) {
  return typeof obj === 'function' || (typeof obj === 'object' && !!obj);
};

The official underscore.js uses this check to find out if something is really an object

// Is a given variable an object?
_.isObject = function(obj) {
  return obj === Object(obj);
};

The official underscore.js uses this check to find out if something is really an object

// Is a given variable an object?
_.isObject = function(obj) {
  return obj === Object(obj);
};

UPDATE

The updated underscore.js library is now using the following, because of a previous bug in V8 and minor micro speed optimization.

// Is a given variable an object?
_.isObject = function(obj) {
  return typeof obj === 'function' || (typeof obj === 'object' && !!obj);
};
Bounty Awarded with 100 reputation awarded by Oriol
Source Link
Daan
  • 8k
  • 5
  • 47
  • 54
Loading