TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript Symbol

JavaScript Symbol with examples on javascript symbol methods, javascript symbol property, javascript tutorial, hasInstance, isConcatSpreadable, match, prototype, search, for(), keyFor(), toString(), unscopables, toPrimitive, split etc.

<< Back to JAVASCRIPT

JavaScript Symbol

The JavaScript Symbol is a function that is used to identify the object properties.

Points to remember

  1. A Symbol() method always return a unique value.
  2. A symbol value may be used as an identifier for object properties.
  3. Symbols are immutable, just like numbers or strings.
  4. Symbols cannot be typecasted to primitive data types.

Syntax

Symbol([description])

Parameters

description: It is optional. We can pass string as an argument.

JavaScript Symbol Property

Let's see the list of JavaScript Symbol properties with their description.

Symbol.hasInstance It is used to determine if a constructor object recognizes an object as its instance.
Symbol.isConcatSpreadable It is used to configure if an object should be flattened to its array elements.
Symbol.match It is a method to identify the matching of a regular expression against a string.
Symbol.prototype It is used for produce the prototype for the symbol constructor.
Symbol.replace It replace matched substring of a string.
Symbol.search It returns the index within a string that matches with the regular expression.
Symbol.split It splits a string at the indices that match the regular expression.
Symbol.toPrimitive It is used to convert an object to its equivalent primitive value.
Symbol.unscopables It is a well-known object property whose property name are excluded from with environment.

JavaScript Symbol Methods

Let's see the list of JavaScript Symbol Method with their description.

Symbol.for() 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.
Symbol.keyFor() 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.
Symbol.toString() It is used to return a string representation of an object.

Next TopicJavaScript Symbol




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf