Unsubscribe
---
Brian Corrigan
Managing Partner / Principal Engineer at MadGlory
https://www.linkedin.com/company/2657284
Wb: http://madglory.com http://www.madglory.com
Tw: @madglory
Ph: 518.867.1439
On Sun, Jun 7, 2015 at 8:00 AM, es-discuss-requ...@mozilla.org wrote:
Send es-discuss mailing list submissions to
es-discuss@mozilla.org
To subscribe or unsubscribe via the World Wide Web, visit
https://mail.mozilla.org/listinfo/es-discuss
or, via email, send a message with subject or body 'help' to
es-discuss-requ...@mozilla.org
You can reach the person managing the list at
es-discuss-ow...@mozilla.org
When replying, please edit your Subject line so it is more specific
than Re: Contents of es-discuss digest...
Today's Topics:
1. Re: Reflect.type (Thaddee Tyl)
2. Re: Reflect.type (Jordan Harband)
-- Forwarded message --
From: Thaddee Tyl thaddee@gmail.com
To: Alexander Jones a...@weej.com
Cc: es-discuss@mozilla.org es-discuss@mozilla.org
Date: Sat, 6 Jun 2015 15:32:46 +0200
Subject: Re: Reflect.type
You suggest a list of types of fixed size. The lack of exposition of
user-definable value types is a problem you mention.
Having a better typeof is not as useful as having a better instanceof.
This would be more valuable:
```js
isA(42, Number) === true // Doesn't work with instanceof
isA([1,3], Array) === true // Does work with instanceof
isA({one:1}, Object) === true // The distinction between array and
object was always weird with typeof
class Thing {}
isA(new Thing, Thing) === true
class SubThing {}
isA(new SubThing, Thing) === true // Detects subclassing / prototype
chain (which instanceof does not do)
```
JS needs Ruby's is_a?.
-- Forwarded message --
From: Jordan Harband ljh...@gmail.com
To: Thaddee Tyl thaddee@gmail.com
Cc: es-discuss@mozilla.org es-discuss@mozilla.org
Date: Sat, 6 Jun 2015 09:23:26 -0700
Subject: Re: Reflect.type
How would your `isA` work across realms, taking a built-in constructor?
`[1,2] instanceof Array` does not, which is why `Array.isArray` exists.
`Object(42) instanceof Number` would have the same problem.
if `class SubThing extends Thing {}`, then `new SubThing instanceof Thing`
would be true.
Based on your isA examples, `Object(foo) instanceof bar` should be
reliable within a single realm, and works everywhere, without the need for
a new builtin method.
On Sat, Jun 6, 2015 at 6:32 AM, Thaddee Tyl thaddee@gmail.com wrote:
You suggest a list of types of fixed size. The lack of exposition of
user-definable value types is a problem you mention.
Having a better typeof is not as useful as having a better instanceof.
This would be more valuable:
```js
isA(42, Number) === true // Doesn't work with instanceof
isA([1,3], Array) === true // Does work with instanceof
isA({one:1}, Object) === true // The distinction between array and
object was always weird with typeof
class Thing {}
isA(new Thing, Thing) === true
class SubThing {}
isA(new SubThing, Thing) === true // Detects subclassing / prototype
chain (which instanceof does not do)
```
JS needs Ruby's is_a?.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss