1
00:00:01,270 --> 00:00:02,090
Hello friends.

2
00:00:02,110 --> 00:00:03,280
Nice to see you back.

3
00:00:03,640 --> 00:00:07,510
In this video we are going to use symbol inside the object.

4
00:00:07,930 --> 00:00:09,970
So I'm going to remove these lines.

5
00:00:10,510 --> 00:00:16,540
And I'm going to create a new symbol late age.

6
00:00:17,680 --> 00:00:19,360
Equal to symbol.

7
00:00:20,920 --> 00:00:21,730
For now.

8
00:00:21,730 --> 00:00:22,600
It's empty.

9
00:00:23,140 --> 00:00:25,220
And then I'm going to create an object.

10
00:00:25,240 --> 00:00:27,880
So I'm going to take a variable name for object.

11
00:00:28,280 --> 00:00:30,550
Late user.

12
00:00:31,380 --> 00:00:33,560
Equal to inside the curly braces.

13
00:00:33,570 --> 00:00:35,280
Here I'm going to create the object.

14
00:00:35,700 --> 00:00:39,930
And we know we need to use value and key to create an object.

15
00:00:40,230 --> 00:00:42,150
Our first object key is name.

16
00:00:43,650 --> 00:00:46,380
And its value is at one.

17
00:00:47,100 --> 00:00:54,390
And our second object is class and it its value is class ten.

18
00:00:54,540 --> 00:00:57,780
And now I want to use this symbol as a key.

19
00:00:58,500 --> 00:01:01,590
In that case first we need to use square braces.

20
00:01:02,280 --> 00:01:04,950
And then we need to type symbol variable.

21
00:01:07,510 --> 00:01:08,260
H.

22
00:01:08,950 --> 00:01:10,210
And we need to provide value.

23
00:01:10,210 --> 00:01:12,100
So I'm going to type 25.

24
00:01:12,130 --> 00:01:17,320
It's a numeric value when we need to use symbol as the key inside the object.

25
00:01:17,710 --> 00:01:20,020
Then we need to use square braces.

26
00:01:20,020 --> 00:01:24,100
And inside the square braces we need to provide symbol variable.

27
00:01:24,460 --> 00:01:26,500
Let's try to print this object inside the console.

28
00:01:26,500 --> 00:01:36,040
So I'm going to type console dot log inside the parentheses our object name user user semicolon.

29
00:01:36,040 --> 00:01:36,820
To end this line.

30
00:01:36,820 --> 00:01:43,300
If I save this file you can see in my console it's print the object for our first video.

31
00:01:43,300 --> 00:01:45,550
It's print name second value it's print class.

32
00:01:45,910 --> 00:01:48,490
But for our third value it's print symbol.

33
00:01:48,790 --> 00:01:51,760
And we do not provide any description to our symbol.

34
00:01:52,210 --> 00:01:57,400
If you want then you can as a symbol value I'm going to type H.

35
00:01:58,150 --> 00:02:02,470
If I save this file this time it print symbol H.

36
00:02:03,010 --> 00:02:06,730
And there is another method to use symbol in our object.

37
00:02:06,730 --> 00:02:08,230
So I'm going to remove it.

38
00:02:08,650 --> 00:02:10,090
And also I remove this comma.

39
00:02:10,900 --> 00:02:14,020
And now I'm going to use this symbol in this object.

40
00:02:14,230 --> 00:02:19,720
So outside the object first I'm going to type object name user.

41
00:02:20,140 --> 00:02:27,340
And inside the square braces I'm going to take symbol variable name age equal to.

42
00:02:27,460 --> 00:02:30,850
And I'm going to assign a value 23.

43
00:02:31,120 --> 00:02:34,630
So this is the another way we can use symbol with object.

44
00:02:35,320 --> 00:02:39,700
So if I save this file you can see in my console it print out proper value.

45
00:02:40,000 --> 00:02:48,070
And as you know if you want to see the exact value of any key, you can just you need to type user dot

46
00:02:48,220 --> 00:02:49,150
class.

47
00:02:50,130 --> 00:02:54,630
If I save this file, you can see it's written the exact value plus ten.

48
00:02:55,140 --> 00:02:57,480
And if I want to show the symbol value.

49
00:02:58,320 --> 00:02:59,790
We cannot use this method.

50
00:03:00,360 --> 00:03:02,310
Let me show you if we try.

51
00:03:02,340 --> 00:03:06,930
So I'm going to duplicate this line and I'm going to change this variable name H.

52
00:03:07,650 --> 00:03:09,120
And if I save this code.

53
00:03:10,010 --> 00:03:10,640
You can see it.

54
00:03:10,640 --> 00:03:12,110
Print undefined.

55
00:03:12,380 --> 00:03:13,670
Class is our key.

56
00:03:13,820 --> 00:03:16,740
Edge is our key, but it works with class.

57
00:03:16,760 --> 00:03:18,980
Then why it is not work with edge.

58
00:03:19,190 --> 00:03:21,620
If we want to show exact single value.

59
00:03:21,650 --> 00:03:24,380
In that case, we don't need to use dot.

60
00:03:24,530 --> 00:03:26,890
We need to use square braces.

61
00:03:26,900 --> 00:03:30,290
So we need to move this variable inside the square braces.

62
00:03:30,620 --> 00:03:34,020
If I save this code you can see now it's written the result.

63
00:03:34,040 --> 00:03:37,850
So you need to remember for normal data type we can use dot.

64
00:03:37,880 --> 00:03:41,390
But for simple data type we need to use square braces.

65
00:03:42,050 --> 00:03:46,910
As you know we can print every object key or value using foreign loop.

66
00:03:47,180 --> 00:03:52,160
So let's use foreign loop and try to print every key in our console.

67
00:03:52,190 --> 00:03:55,580
So I'm going to type four inside the parenthesis.

68
00:03:55,620 --> 00:03:58,880
Let key in user.

69
00:03:59,240 --> 00:04:00,990
User means our object name.

70
00:04:01,010 --> 00:04:07,880
Then inside the curly braces console dot log inside the parenthesis key.

71
00:04:08,330 --> 00:04:14,060
If I run this code it going to print student name user name user class.

72
00:04:14,060 --> 00:04:18,380
But it is going to skip user is because it is a symbol.

73
00:04:18,830 --> 00:04:20,300
So I'm going to save this file.

74
00:04:20,570 --> 00:04:26,580
Now you can see in my console it print name class but it doesn't print each key.

75
00:04:26,600 --> 00:04:29,270
So it's print only to key name in class.

76
00:04:29,780 --> 00:04:36,520
But if I duplicate this line and try to insert another key name gender and his gender is male.

77
00:04:36,530 --> 00:04:38,060
So I'm going to type male.

78
00:04:38,870 --> 00:04:44,540
If I save this file, you can see it prints three key from our object name, class and gender.

79
00:04:44,540 --> 00:04:48,020
But it escape key because it's a symbol.

80
00:04:48,170 --> 00:04:50,990
So we cannot use symbol inside the foreign loop.

81
00:04:50,990 --> 00:04:53,240
And you need to remember it always.

82
00:04:53,240 --> 00:04:56,060
And you know why we use JavaScript object?

83
00:04:56,270 --> 00:05:02,300
Because we convert JavaScript object into a Json object and try to send data to the server.

84
00:05:02,570 --> 00:05:07,880
And if I try to convert this user object into a Json, once again it skip this value.

85
00:05:07,910 --> 00:05:09,230
Let me show you this.

86
00:05:09,350 --> 00:05:14,270
You can see we have four value in our object name, class, age, and gender.

87
00:05:14,420 --> 00:05:16,010
So first I'm going to remove this.

88
00:05:16,010 --> 00:05:17,150
I don't need this for loop.

89
00:05:17,420 --> 00:05:20,990
And now I'm going to convert this object into a Json file.

90
00:05:20,990 --> 00:05:25,100
So I'm going to use console dot log.

91
00:05:25,130 --> 00:05:31,490
Inside the parentheses I'm going to use json Stringified method json dot Stringify.

92
00:05:32,090 --> 00:05:37,730
Inside the parentheses I'm going to provide our object name, which is user.

93
00:05:38,150 --> 00:05:42,140
If I save this file you can see it returns a Json object.

94
00:05:42,230 --> 00:05:45,200
But if you notice edge value is missing.

95
00:05:45,650 --> 00:05:49,160
But if I just print this object in our console let's see.

96
00:05:49,280 --> 00:05:51,170
So I'm going to remove this parenthesis.

97
00:05:51,170 --> 00:05:56,630
And if I save this file you can see you can see my console symbol value.

98
00:05:56,810 --> 00:05:59,510
But in my Json object there is no symbol value.

99
00:05:59,720 --> 00:06:06,830
So we need to remember whenever we use symbol value in our object, we cannot use this value in our

100
00:06:06,830 --> 00:06:07,790
foreign loop.

101
00:06:07,790 --> 00:06:11,270
And also we cannot convert this value into a Json object.

102
00:06:11,270 --> 00:06:17,960
And if you really want to convert it, then we need to convert this symbol value into a string.

103
00:06:18,140 --> 00:06:24,440
As I told you earlier, we use the description method to convert the symbol into a string, and then

104
00:06:24,440 --> 00:06:26,810
we can convert it into a Json object.

105
00:06:27,080 --> 00:06:30,620
We do not directly convert symbol into a Json object.

106
00:06:30,920 --> 00:06:35,990
So basically this is our new datatype symbol symbols mean unique value.

107
00:06:36,110 --> 00:06:37,880
It is rarely used.

108
00:06:38,090 --> 00:06:39,530
I hope now it's clear for you.

109
00:06:39,560 --> 00:06:40,660
What is symbol datatype?

110
00:06:40,670 --> 00:06:42,140
Thanks for watching this video.
