Here.
You can see I opened my Visual Studio Code editor, and I also create a HTML file.
And I open this HTML file using live server extension in this browser.
First I'm going to type script tag.
Inside the script tag, I am going to create a symbol.
So I'm going to create a variable.
Let ID equal to S should be capital symbol.
Let's print this symbol in our console.
So I'm going to type console dot log inside the parentheses id.
If I save this file you can see in my console it print.
It's a symbol.
And I'm going to assign a identifier to the symbol.
So I'm going to type hello.
It may be string, may be number, whatever.
And if I set this file you can see my console.
It's print.
Hello.
And if I show you the data type.
So I'm going to duplicate this line.
And I'm going to print.
Type of ID.
And if I save this file, you can see it's been symbol.
Symbols mean one unique value.
Let's try to prove it.
How it is a unique value.
So I'm going to duplicate this line and change the name ID to.
You can see it's looking same and their value is same.
But if I compare this to variable it's return false.
Let's compare it.
ID equals to equals to id two.
If I save this file you can see it returns false.
Its mean these two variables values are not same.
Its look pretty similar but it is not same.
But if we use string let me show you that.
So I'm going to duplicate this line.
And I'm going to change the name as tr one and str two.
Now they are string, not symbols.
So I'm going to remove this symbol keyword.
And also I'm going to remove this one.
And now I'm going to compare this to value.
So inside console dot log section I'm going to type T, r1 and str2 and I'm going to comment out this
one.
If I save this file you can see it returned true because in that case they are not symbol.
They are string.
And two variables.
Values are same.
They are not unique value.
One thing remember we cannot use symbol value directly in our document.
Let me show you that.
So I'm going to remove this lines.
I don't need this lines for now.
And also I'm going to remove these lines.
As I say, we cannot print symbol value in our document.
If I try to print.
So I'm going to use a alert.
Alert inside the parentheses I'm going to print ID.
If I run this code it's written error.
So I'm going to save this code.
And you can see type error.
And also it print cannot convert a symbol value to a string.
If you want to convert symbol value into a string then you need to use some method to convert symbol
value into a string.
Let me show you that.
So we need to use two string method id dot two string.
Using this method we can convert symbol variable into a string.
If I save this file now, it's work properly.
You can see in my alert symbol.
Hello.
So we need to use two string method to convert symbol into a string.
And then we can use this symbol value in our document.
And if you want to see the exact value of symbol then we need to use a different method.
In that case we do not use two string method.
So I'm going to remove it and I'm going to type id dot description.
It's a not a function, so we don't need to use round braces.
It is just a simple method.
So if I save this file, you can see in my alert section.
Now it is just print.
Hello means our message.
In the next part of this video I am going to show you how can we use symbol into a object?