Function that checks if array only contains elements of a specific type
The implementation could be written more compactly using arrow functions, for example:

if (type === null || type === undefined) {
  return arr.every(e =&gt; e === type);
}

return arr.every(e =&gt; Object.getPrototypeOf(Object(e)) === type.prototype);


There are two arr.every calls at different execution paths.
You could eliminate that duplicated logic by extracting the function parameter of arr.every to a variable:

var checker;
if (type === null || type === undefined) {
  checker = e =&gt; e === type;
} else {
  checker = e =&gt; Object.getPrototypeOf(Object(e)) === type.prototype;
}

return arr.every(checker);