Points to remember
- A Symbol() method always return a unique value.
- A symbol value may be used as an identifier for object properties.
- Symbols are immutable, just like numbers or strings.
- Symbols cannot be typecasted to primitive data types.
description: It is optional. We can pass string as an argument.
||It is used to determine if a constructor object recognizes an object as its instance.
||It is used to configure if an object should be flattened to its array elements.
||It is a method to identify the matching of a regular expression against a string.
||It is used for produce the prototype for the symbol constructor.
||It replace matched substring of a string.
||It returns the index within a string that matches with the regular expression.
||It splits a string at the indices that match the regular expression.
||It is used to convert an object to its equivalent primitive value.
||It is a well-known object property whose property name are excluded from with environment.
||It is used to search for existing symbol in a runtime-wide symbol registry with the provided key and returns if it is found. Otherwise new symbol gets created with this key.
||It uses the global symbol registry to look up the key for the symbol. So it doesn't work for non-global symbols. If the symbol is not global, it won't be able to find it and returns undefined.
||It is used to return a string representation of an object.