2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScript便利関数表(随時更新)

Last updated at Posted at 2021-08-07

まだ数は少ないですが、便利だと思うJavaScriptの関数をまとめていきます。
時々、汎用性の高い良い書き方を見つけたら追加していく予定です。

Sleep関数

const sleep = function (msec) {
  return new Promise(function(resolve) {
    setTimeout(function() { resolve() }, msec);
  });
}
export default sleep

// 以下のように呼び出す
async function() {
 // something
 await sleep(1000);
 // something
}

オブジェクトの中から特定のキーを検索

// jsonが検索したいオブジェクト
// wantが検索キー
Object.entries(json).find(([key, _]) => {
  return key === want;
})
2
3
2

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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?