RE: Fetch API

From: Tab Atkins Jr. [mailto:jackalmage@gmail.com] 

> Using NamedConstructor is identical to doing:
>
> ```js
> class Foo { ... }
> let Bar = Foo;
> // now I can do "new Foo()" or "new Bar()", to the same effect.
> ```

Not true, since the constructors take different arguments. Instead it is equivalent to

```js
class Response {
  constructor(body, init) { ... }
  ...
}

function RedirectResponse(url, status = 302) {
  return new Response(???, ???);
}
RedirectResponse.prototype = Response.prototype;
```

> What invariants are you concerned about?

In particular, we have that

```js
RedirectResponse.prototype.constructor !== RedirectResponse
(new RedirectResponse(...)).constructor !== RedirectResponse
// Also, omitting the `new` does not throw a `TypeError`, like it does for real constructors.
```

and possibly a few others I am forgetting.

Received on Sunday, 1 June 2014 21:19:41 UTC