5 ms·
JS used to have those, now they are deprecated though: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__
by c6401 1y ago
JS used to have those, now they are deprecated though:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__#examples https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
so it settled on having this syntax for similar cases using "Symbol":
class Foo {
*[Symbol.iterator]() {
yield 1;
yield 2;
yield 3;
}
}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#static_properties https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...