Kim Gysen Kim Gysen - 18 days ago 5
Javascript Question

Convention of @@

What is the convention behind the double at (

@@
) in method declarations?

For example from:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols


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.

Answer

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];