Kim Gysen Kim Gysen - 6 months ago 40
Javascript Question

Convention of @@

What is the convention behind the double at (

) in method declarations?

For example from:

Whenever an object needs to be iterated (such as at the beginning of a
for..of loop), its @@iterator method is called with no arguments, and
the returned iterator is used to obtain the values to be iterated.


That's a specification shorthand for "well-known symbols," rather than something you'd type literally. For instance, @@iterator is Symbol.iterator, which is the key you'd use to get the default iterator for an object:

let defaultIterator = theObject[Symbol.iterator];