JAVASCRIPT   158

is-plain-array.js

Guest on 9th September 2021 04:43:44 PM

  1. "use strict";
  2.  
  3. var SubArray = require("../../array/_sub-array-dummy-safe");
  4.  
  5. module.exports = function (t, a) {
  6.         var arr = [1, 2, 3];
  7.         a(t(arr), true, "Array");
  8.         a(t(null), false, "Null");
  9.         a(t(), false, "Undefined");
  10.         a(t("234"), false, "String");
  11.         a(t(23), false, "Number");
  12.         a(t({}), false, "Plain object");
  13.         a(t({ length: 1, 0: "raz" }), false, "Array-like");
  14.         a(t(Object.create(arr)), false, "Array extension");
  15.         if (!SubArray) return;
  16.         a(t(new SubArray(23)), false, "Subclass instance");
  17.         a(t(Array.prototype), false, "Array.prototype");
  18. };

Raw Paste


Login or Register to edit or fork this paste. It's free.