Skip to content

Support invocation with no this #16

@bakkot

Description

@bakkot

It's nice to be able to treat functions like Set.from as actual functions which can be passed around, so that you can do stuff like let sets = [ [0, 1], [2, 3] ].map(Set.from). As currently spec'd this does not work because of the If IsConstructor(C) is false, throw a TypeError exception. step.

I think it would make sense to match the behavior of Array.from, which has the behavior of using the realm-default constructor for Array when the this value is not constructible. That way you get the subclassing behavior (where class MyMap extends Map {}; MyMap.of() instanceof MyMap /* true */;) while still allowing the functional-style invocation above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions