fiddle.js icon indicating copy to clipboard operation
fiddle.js copied to clipboard

Use Array#isArray instead of instanceof

Open rauchg opened this issue 13 years ago • 2 comments

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 avatar May 08 '12 23:05 rauchg

This also applies to dref.js

rauchg avatar May 08 '12 23:05 rauchg

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.

crcn avatar May 09 '12 15:05 crcn