Some JavaScript (ECMAScript) features are easier to understand than others. Generators
look weird — like pointers in C/C++. Symbols
manage to look like both primitives and objects at the same time.
These features are all inter-related and build on each other. So you can’t understand one thing without understanding the other.
So in this article, I’ll cover symbols
,global symbols
,iterators
, iterables
, generators
, async/await
and async iterators
. I’ll explain “why” they are there in the first place and also show how they work with some useful examples.
This is relatively advanced subject, but it’s not rocket science. This article should give you a very good grasp of all these concepts.
OK, let’s get started.🚀
Symbols
In ES2015, a new (6th) datatype called symbol
was created.
WHY?
The three main reasons were: