On Jun 15, 2015, at 9:21 PM, Bradley Meck wrote:
> On the surface `O instanceof C` boxes `C`, but when using `GetMethod` O turns
> O into an Object. This means `instanceof` is temporarily turning O into an
> Object.
Read the spec
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-relati
On the surface `O instanceof C` boxes `C`, but when using `GetMethod` O
turns O into an Object. This means `instanceof` is temporarily turning O
into an Object.
For primitives, all the operators in JS have been unable to be altered
until this was pointed out. `1 instanceof C` is able to be changed
On Jun 15, 2015, at 10:06 AM, Bradley Meck wrote:
> Kyle Simpson caused the discovery of this oddity :
>
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-instanceofoperator
> calls GetMethod on C without checking if it is an Object, this means `1
> instanceof Foo` could be affected
Herby Vojčík wrote:
So when one actually _wants_ to concat (as, add elements of the
iterable), it should stop using concat for that and must do something
like
var concatenated = first.slice();
concatenated.push(...second, ...third, ...fourth);
Or use concat but wrap the parameter with [].
Would not work since @@hasInstance takes priority over OrdinaryHasInstance
and would box it.
On Mon, Jun 15, 2015 at 3:19 PM, Andrea Giammarchi <
andrea.giammar...@gmail.com> wrote:
> so `Object(unknown) instanceof Number` it is then ¯\_(ツ)_/¯
>
> On Mon, Jun 15, 2015 at 9:14 PM, Bradley Meck
>
so `Object(unknown) instanceof Number` it is then ¯\_(ツ)_/¯
On Mon, Jun 15, 2015 at 9:14 PM, Bradley Meck
wrote:
> Well this also has slightly odd behavior since the Object operation will
> fail for OrdinaryHastInstance if for primitives
> https://people.mozilla.org/~jorendorff/es6-draft.html#se
Well this also has slightly odd behavior since the Object operation will
fail for OrdinaryHastInstance if for primitives
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ordinaryhasinstance
On Mon, Jun 15, 2015 at 3:09 PM, Andrea Giammarchi <
andrea.giammar...@gmail.com> wrote:
> point o
point of views I guess, you could fix forever the inconsistency via
```js
Number.prototype[Symbol.hasInstance] = function () {
return typeof this.valueOf() === 'number';
};
```
and fix String, Boolean, Symbol too (why not) and whatever else.
`instanceof` is the new `typeof` ^_^ (naa, just jokin
Yes, with regards to O being an Object.
This seems a bit strange to me since things like:
```
Number.prototype.toString = function () {return 'overriden';}
(1)+'' // "1"
String(1) // "1"
(1).toString() // "overriden"
```
Implicit string coercion does not box the object.
String constructor do
Allen Wirfs-Brock wrote:
On Jun 3, 2015, at 3:46 AM, Leon Arnott wrote:
This reminds me: I feel like the spec should've added
Array.prototype[Symbol.isConcatSpreadable] (value:true,
configurable:false, writable:false), and eliminated the final
IsArray() test from
[22.1.3.11](https://people.mo
>
>
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-instanceofoperator
> calls GetMethod on C without checking if it is an Object, this means `1
> instanceof Foo` could be affected by mutating
> `Number.prototype[Symbol.hasInstance]`.
>
I assume you mean "without checking if O is an ob
I think we can stick a fork in this thread, it's done. Let it
memorialize some knowledge that seems in danger of being lost over time.
Thanks,
/be
Wes Garland wrote:
That root post ignored compatibility constraints that have been discussed to
death over the years, and just glibly asserted th
Kyle Simpson caused the discovery of this oddity :
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-instanceofoperator
calls GetMethod on C without checking if it is an Object, this means `1
instanceof Foo` could be affected by mutating
`Number.prototype[Symbol.hasInstance]`.
I am assumi
Pointing out that I'm replying to a message with an empty subject - using
the correct original title here
-- Forwarded message --
From: Rock
Benjamin Gruenaum, Andrea Giammarchi, you are wrong about RegExp:
```js
var re = /./;
new RegExp(re) === re; // false
RegExp(re) === re; //
You can't accept string or regexp 'cause strings cannot be flags this way
so beside split I don't know where this could work. flags like i, or u, are
also important, being unable to pass these even in split doesn't look like
a good idea, IMO
On Mon, Jun 15, 2015 at 1:22 PM, Denis Pushkarev
wrote:
This logic is convenient if function accept string or regexp, like `String#split`, for convert it to regexp. Behavior with second argument is changed in ES6 and fixed in latest FF, `core-js` and `es6-shim`. Sorry for reply w/o subject - problem with mail client :) 15.06.2015, 17:36, "Andrea Giammar
that's no how usually you create RegExp
```js
RegExp('yep', 'g');
new RegExp('yep', 'g');
```
both will produce similar RegExp instances (every time a new one).
Using the RegExp constructor as RegExp wrapper is a very unusual pattern I
haven't seen before. So yes, in that case we have some sort o
Benjamin Gruenaum, Andrea Giammarchi, you are wrong about RegExp:
```js
var re = /./;
new RegExp(re) === re; // false
RegExp(re) === re; // true
```
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
18 matches
Mail list logo