LoginSignup
0
0

More than 5 years have passed since last update.

劇的ビフォーアフターJS編

Last updated at Posted at 2018-10-13

自分が書いたコード(全部の絵文字を出力するjs)をリファクタリングした https://qiita.com/taroyanaka/items/21b044d84dcf9a65dfb0
この記事凄い良かったから古い書き方のJS各位読んだら嬉しいはず
https://ginpen.com/2017/12/03/arrow-funcitons/
http://js-next.hatenablog.com/entry/2014/07/23/173147

before.js
[...Array(10000000).keys()].map(function(value){
  return String.fromCharCode(value)
}).filter(function(value){
  return /\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/gu.test(value);
})
after.js
[...Array(10000000).keys()]
.map(v=>String.fromCharCode(v))
.filter(v=>/\p{Emoji_Modifier_Base}\p{Emoji_Modifier}|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/gu.test(v))

5行(222文字)→3行(164文字)。匠の手にかかって簡潔になり可読性も向上しました。

余談。chromeのconsoleはshift+enterで改行。知らなかった。

0
0
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
0
0