I'm new to Typescript and Javascript, just a question on Symbol.iterator. We know that we can define an iterable class as:
class iterableExample<T> {
private items: Map<string, T>;
...
[Symbol.iterator]():Iterator<T> {
return this.items.values();
}
}
But what's the syntax of [Symbol.iterator]()
? I think it is index signature but it also looks like a method, how could an index signature also be a method? it is really weird.