If some of the built-ins in lesson 7 were new to you, we hope the following links will help you.
- Symbols: unique and immutable data type often used to identify object properties.
- Symbol Iterator: Read more below (Iterable & Iterator)
- Sets: Object to store unique values
- WeakSet: Object to store unique values
- Sets vs WeakSets
- Map: store key-value pairs
- WeakMap: store key-value pairs
- Map vs WeakMap
- Promises: start some work async and let you get back to your regular work
- Proxies: define custom behavior for fundamental operations
- Generators: returned by a generator function, it conforms to both the iterable & iterator protocol
The iterable protocol is used for defining and customizing the iteration behavior of objects. What that really means is you now have the flexibility in ES6 to specify a way for iterating through values in an object. For some objects, they already come built-in with this behavior. For example, strings and arrays are examples of built-in iterables.
Udacity quote
The iterator protocol is used to define a standard way that an object produces a sequence of values. What that really means is you now have a process for defining how an object will iterate. This is done through implementing the .next() method.
Udacity quote
A WeakSet is just like a normal Set with a few key differences:
- a WeakSet can only contain objects
- a WeakSet is not iterable which means it can’t be looped over
- a WeakSet does not have a .clear() method
In JavaScript, memory is allocated when new values are created and is "automatically" freed up when those values are no longer needed. This process of freeing up memory after it is no longer needed is what is known as garbage collection.
WeakSets take advantage of this by exclusively working with objects. If you set an object to null, then you’re essentially deleting the object. And when JavaScript’s garbage collector runs, the memory that object previously occupied will be freed up to be used later in your program.
Udacity quote
A WeakMap is just like a normal Map with a few key differences:
- a WeakMap can only contain objects as keys,
- a WeakMap is not iterable which means it can’t be looped and
- a WeakMap does not have a .clear() method.
In JavaScript, memory is allocated when new values are created and is "automatically" freed up when those values are no longer needed. This process of freeing up memory after it is no longer needed is what is known as garbage collection.
WeakMaps take advantage of this by exclusively working with objects as keys. If you set an object to null, then you’re essentially deleting the object. And when JavaScript’s garbage collector runs, the memory that object previously occupied will be freed up to be used later in your program.
Udacity quote