Please enable JavaScript.
Coggle requires JavaScript to display documents.
Datatypes - Coggle Diagram
Datatypes
Iterables
Symbol.iterator
we have an object that is not an array, but looks suitable for for..of
-
-
-
-
Methods of primitives
7 primitive types
string, number, bigint, boolean, symbol, null, undefined
-
-
-
Object.keys, values, entries
Method
-
-
Object.entries(obj) – returns an array of [key, value] pairs.
-
Transforming objects
using for apply method of array when it is object, If we’d like to apply them, then we can use Object.entries followed by Object.fromEntries
WeakMap and WeakSet
WeakMap
define
WeakMap is that keys must be objects, not primitive values
note
WeakMap does not support iteration and methods keys(), values(), entries(), so there’s no way to get all keys or values from it.
-
-
Use case: caching
We can store (“cache”) results from a function, so that future calls on the same object can reuse it.
WeakSet
-
Note
It is analogous to Set, but we may only add objects to WeakSet (not primitives).
-
Like Set, it supports add, has and delete, but not size, keys() and no iterations.
-