Overview of ES6 at 350 points. Part two My series of notes
ES6 in Depth , consisting of 24 entries, describes most of the syntax changes and innovations in ES6. In this publication, I will summarize everything stated in previous articles in order to give an opportunity to look again at everything together.
Content Introduction Tools Assignment Destructing Spread Operator and Rest Parameters Arrow functions Pattern lines Object Literals Classes Let and Const Characters Iterators Generators Promises Maps Weakmaps Sets Weaksets Proxy Reflection Number Math Array Object Strings and Unicode Modules Part one:
here. ')
Characters New primitive data type in ES6. You can create your own symbols: var symbol = Symbol()
var symbol = Symbol()
You can add descriptions for Symbol('ponyfoo')
debugging needs Symbol('ponyfoo')
Symbol('ponyfoo')
Symbols are immutable and unique: Symbol()
Symbol()
, Symbol()
Symbol()
, Symbol('foo')
Symbol('foo')
and Symbol('foo')
Symbol('foo')
- all different. Type of symbols - symbol
symbol
so typeof Symbol() === 'symbol'
typeof Symbol() === 'symbol'
. You can create global symbols with Symbol.for(key)
Symbol.for(key)
. If the character with this key
key
exists, the call will return it. Otherwise a new character with key
will be created. key
as a description. Symbol.keyFor(symbol)
Is an inverse function that accepts symbol
symbol
and returning its key
key
.Global symbols are global, as far as possible, that is, absolutely. For access to symbols, a single global register is used: context window
window
; eval
context eval
;context .
Source: https://habr.com/ru/post/270697/All Articles