forEach method of Node.childNodes?

前端 未结 2 762
时光取名叫无心
时光取名叫无心 2020-11-28 14:31

After providing an incorrect answer concerning the .item() property of Node.childNodes for a question, I inspected __proto__ of the returned

2条回答
  •  一整个雨季
    2020-11-28 15:04

    DOM4 now defines NodeList as an iterable:

    iterable;
    

    According to the IDL draft, that means

    An interface can be declared to be iterable by using an iterable declaration (matching Iterable) in the body of the interface.

    iterable;
    iterable;
    

    Objects implementing an interface that is declared to be iterable support being iterated over to obtain a sequence of values.

    Note: In the ECMAScript language binding, an interface that is iterable will have “entries”, “forEach”, “keys”, “values” and @@iterator properties on its interface prototype object.

    If a single type parameter is given, then the interface has a value iterator and provides values of the specified type.

提交回复
热议问题