mortal-cultivation-biography / daydayup

A FE interview-questions collection repo.
8 stars 0 forks source link

实现 Array.prototype.map #15

Open nmsn opened 1 year ago

nmsn commented 1 year ago

如题

nmsn commented 1 year ago
Array.prototype._map = function (exc) {
  const result = [];
  this.forEach((item, index, arr) => {
    result[index] = exc(item, index, arr)
  });
  return result;
}