Skip to content

Array.from() 的問題 #8

Description

@jawayang

想問一下昨天導讀的內容
裡面有個範例

let ps = document.querySelectorAll('p');
Array.from(ps).forEach(function (p) {
  console.log(p);
});

Array.from 是用來把物件轉成陣列對吧?
document.querySelectorAll 回來的結果不是 陣列嗎?
還是他是類陣列?
還是其實陣列也是類陣列的一種?
為何這邊還需要用 Array.from() 去包 ps?
求解~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions