- From: Domenic Denicola <notifications@github.com>
- Date: Fri, 05 Dec 2014 11:47:14 -0800
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
Received on Friday, 5 December 2014 19:47:40 UTC
@jakearchibald this is your brain on readonly no-[Replacable]:
```js
class Foo {
constructor() {
this._bar = 5;
}
get bar() {
return this._bar;
}
}
```
This is your brain on readonly [Replacable]:
```js
class Foo {
constructor() {
this._bar = 5;
}
get bar() {
return this._bar;
}
set bar(v) {
Object.defineProperty(this, "bar", {
writable: true,
enumerable: true,
configurable: true,
value: v
});
}
}
```
For comparison this is non-readonly (and thus non-[Replacable])
```js
class Foo {
constructor() {
this._bar = 5;
}
get bar() {
return this._bar;
}
set bar(v) {
this._bar = v;
}
}
```
See also the example at https://heycam.github.io/webidl/#Replaceable
---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/535#issuecomment-65843874
Received on Friday, 5 December 2014 19:47:40 UTC