crcn / fiddle.js

mongodb-inspired object manipulation
MIT License
31 stars 3 forks source link

Use Array#isArray instead of instanceof #1

Open rauchg opened 12 years ago

rauchg commented 12 years ago

And if you plan to support browser, use this instead

/**
 * Checks for Array type.
 *
 * @param {Object} object
 * @api private
 */

function isArray (obj) {
  return '[object Array]' == Object.prototype.toString.call(obj);
};
rauchg commented 12 years ago

This also applies to dref.js

crcn commented 12 years ago

I think generally it'd be good practice for me to start using Array.isArray versus value instanceof Array for this very reason. Made note of it. Thanks for pointing it out.