Skip to content

Instantly share code, notes, and snippets.

@tpps88206
Created December 11, 2020 09:03
Show Gist options
  • Save tpps88206/a52e31fab24594b55aa96a923adfbe5f to your computer and use it in GitHub Desktop.
Save tpps88206/a52e31fab24594b55aa96a923adfbe5f to your computer and use it in GitHub Desktop.
在 JavaScript 中實作 concatAll 函數
Array.prototype.concatAll = function() {
var result = [];
// 用 apply 完成
this.forEach((array) => {
result.push.apply(result, array);
});
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment