0
0

Array.from()

Posted at

Array.from()

Array.from() 静的メソッドは、反復可能オブジェクトや配列風オブジェクトからシャローコピーされた、新しい Array インスタンスを生成します。

console.log(Array.from('foo'));
// Expected output: Array ["f", "o", "o"]

console.log(Array.from([1, 2, 3], (x) => x + x));
// Expected output: Array [2, 4, 6]

出典

HTMLCollectionでも配列を作ることができる

idを基にしたhtmlの要素を取得した後、forEachで繰り返し処理ができないがこれを使えばできる

出典

感想

これで子要素に繰り返し処理ができる

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