Re:What’s New in ES2019
by snek on Tuesday July 30, 2019 @10:26AM
(#20565087)
In JS, the pattern is the type. That is the point of duck typing.
[ Parent
| on HN ]
Re:What’s New in ES2019
by SomeOldThrow on Tuesday July 30, 2019 @04:28PM
(#20568783)
> In JS, the pattern is the type.
How do you match against a `Buffer` pattern/type?
In 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.
Re:What’s New in ES2019
by SomeOldThrow on Wednesday July 31, 2019 @01:35AM
(#20571921)
Oh interesting you can match on that!
However I think my point stands that javascript has runtime conceptions of types that go beyond duck typing.