3

I am learning typescript from past few days and came across a data type called Symbol. But I really did not understand the applications of it.

When I can assign a string to a variable like below:

let str="mystring";

Why should I use -

 let str=Symbol("mystring");

What is the advantage of using Symbol in typescript? What is the need of this data type and when to use it? Can someone explain please.

Jinesh
  • 1,480
  • 2
  • 25
  • 52
  • 2
    The docs look pretty self explanatory to me https://www.typescriptlang.org/docs/handbook/symbols.html – Kurt Hamilton Feb 18 '20 at 10:59
  • Does this answer your question? [Sense of symbols in TypeScript](https://stackoverflow.com/questions/51945296/sense-of-symbols-in-typescript) – rmjoia Feb 18 '20 at 10:59
  • 4
    yes I went through this document but they only guide about how to use it. But my question is when to use it. – gangothri urs Feb 18 '20 at 11:02

0 Answers0