LoginSignup
1
1

More than 5 years have passed since last update.

smoosh, squash, flatten?

Posted at

Smoosh, squash, flatten?

TC39ではflattenという関数(ネストされた配列をフラットにする)の名前をsmooshとかsquashにしたほうがいいんじゃないかという議論がされている。ちなみに、TC39はECMAScriptに関する提案を扱う委員会のこと。

flattenの動きはこんな感じ(になる予定?定かではない)

const a = [1, [2, 3, 4], 5];
flatten(a); // -> [1, 2, 3, 4, 5]

なぜflattenではまずいかというと、MooToolsというユーティリティライブラリにflattenという関数がありTC39で提案されている関数と互換性がないため。

個人的にはflattenになってほしい。多くのライブラリがflattenという名前を採用している気がするから。

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1