3 ms·
In JS, the pattern is the type. That is the point of duck typing.
by snek 7y ago
In JS, the pattern is the type. That is the point of duck typing.
- SomeOldThrow 7y ago> In JS, the pattern is the type. How do you match against a `Buffer` pattern/type?
- vimslayer 7y agoIn the current proposal, case (value) { when { constructor: Buffer } -> console.log("It's a Buffer!") } that doesn't handle subtying though and doesn't work across realms.
- SomeOldThrow 7y agoOh interesting you can match on that! However I think my point stands that javascript has runtime conceptions of types that go beyond duck typing.