Metaprogramming refers to the programming that takes the operation target as the behavior characteristic of the program itself. In ES6, the type symbol is added. In addition to the custom symbol, some other built-in symbols are also predefined, which can be called the built-in symbols. Here’s a look at some of these in-game symbols.

1. The Symbol. Iterator represents a specific attribute on any object. The language mechanism automatically looks for a method on that attribute that will construct an iterator to consume the object's value. ... Expand and the for... The of loop uses it automatically. We can also define our own iterator logic for any object value by customizing the Symbol.iterator property, which will override the default iterator. We've essentially defined a metaprogramming behavior that other parts of JavaScript (i.e., operators and loop structures) can use when dealing with defined objects. 2. Symbol.toStringTag and Symbol.hasInstance A common scenario in everyday logic to determine what type of page game a value is, usually using toString() and instanceof. Now in ES6, you can define the behavior characteristics of these operations. The toStringTag symbol specifies the value of the string to be used when [Object XXXX] is stringed. The hasInstance symbol is a method on the constructor function that takes the value of an instance object and indicates whether the value can be considered an instance by returning www.walajiao.comtrue or false. On Function.prototype, hasInstance defaults to false writable and cannot be written. You can circumvent this by using Object.defineProperty(). 3. Symbol.species This Symbol controls which constructor is used by the class's built-in methods to generate a new instance. The default behavior of the built-in native constructor Symbol.species is return this. If you want to generate a new instance defined, use the new enclosing constructorSymbol. Species, and then inherited classes can according to it to control by which the constructor to create the instance.

How can I call up the page game symbol

Prior to ES6, there was no control over the behavior of objects that had to be cast to a native type for an operation (such as add + or compare ==). This behavior can now be controlled through the Symbol symbol.toprimitive. The Symbol.toprimitive method provides a type (type) specifying "string", "number", or "default", depending on the type expected by the operation that called toPrimitive. The above is the introduction of ES6 Symbol, I hope it can help you.