Non-standard Array generics have been removed

Published: | Categories: JavaScript

Description

The non-standard, Firefox-specific Array generic methods, introduced with JavaScript 1.6 and deprecated since Firefox 68, have been removed with Firefox 71. These generic/static methods include:

  • Array.concat
  • Array.every
  • Array.filter
  • Array.forEach
  • Array.indexOf
  • Array.join
  • Array.lastIndexOf
  • Array.map
  • Array.pop
  • Array.push
  • Array.reduce
  • Array.reduceRight
  • Array.reverse
  • Array.shift
  • Array.slice
  • Array.some
  • Array.sort
  • Array.splice
  • Array.unshift

Here are some alternatives to the generics:

// Deprecated
Array.forEach(obj, callback);
// Alternative 1: the spread syntax
[...obj].forEach(callback);
// Alternative 2: the Array.from method
Array.from(obj).forEach(callback);
// Alternative 3: the old-school way
// (if the object is not yet iterable)
Array.prototype.forEach.call(obj, callback);

Note that the standard instance methods on Array.prototype won’t be affected, of course. The following static methods are also in the ECMAScript 2015 (ES6) spec and therefore they won’t be removed:

References