1 00:00:01,620 --> 00:00:02,460 What's up, everyone? 2 00:00:02,490 --> 00:00:08,140 Today, we're going to learn about variable type coercion and mediation. 3 00:00:08,490 --> 00:00:21,750 So these are very important aspects of JavaScript language basics right now, what coercion and mutation 4 00:00:21,750 --> 00:00:22,140 means. 5 00:00:22,170 --> 00:00:23,160 Sorry about this. 6 00:00:23,160 --> 00:00:26,020 I'm just going to wait here to open this one now. 7 00:00:26,670 --> 00:00:41,670 What I'm going to do is actually we are going to put it here and say variable type coercion and mutation. 8 00:00:44,790 --> 00:00:45,150 Very good. 9 00:00:45,300 --> 00:00:47,240 Now you hit it, right? 10 00:00:47,400 --> 00:00:47,790 No. 11 00:00:50,680 --> 00:00:51,300 That's it. 12 00:00:51,600 --> 00:00:58,540 Now we're going to do we do have the first name and I'm not going to comment on this one, but we can 13 00:00:58,540 --> 00:01:00,240 comment on all of this. 14 00:01:00,400 --> 00:01:06,190 So if I refresh, I'm not going to I'm going to be hello world from external file. 15 00:01:07,420 --> 00:01:08,470 That's one from here. 16 00:01:09,490 --> 00:01:10,660 And that's all good. 17 00:01:11,410 --> 00:01:12,910 I don't have to be worried about that. 18 00:01:12,910 --> 00:01:15,850 So you can comment the section of the code like this. 19 00:01:15,850 --> 00:01:20,050 And that is what also comments are therefore. 20 00:01:20,200 --> 00:01:24,220 So not just to make a comment about what you what your coat will be about. 21 00:01:24,580 --> 00:01:29,200 And also sometimes you need to comment on things in order to continue working on something else. 22 00:01:29,620 --> 00:01:30,020 Nice. 23 00:01:30,460 --> 00:01:36,700 So what is type coersion? 24 00:01:36,700 --> 00:01:40,420 So we have the first name, we have the last name. 25 00:01:40,870 --> 00:01:49,950 And what we can do here is we can just put those together like in one. 26 00:01:50,320 --> 00:01:53,050 I'm not I'm just going to say Konz a lot. 27 00:01:56,480 --> 00:02:05,810 Guns a lot, and I am going to join the EU first name, so how we can join the things, we can join 28 00:02:05,810 --> 00:02:07,750 the things with the plus symbols. 29 00:02:07,750 --> 00:02:10,520 So this is not addition here. 30 00:02:10,520 --> 00:02:11,960 Underscore last night. 31 00:02:13,070 --> 00:02:13,360 Right. 32 00:02:14,540 --> 00:02:21,260 So if I do it like this, so this is not going to be a first name plus last name, it will be joined 33 00:02:21,620 --> 00:02:22,310 actually. 34 00:02:24,200 --> 00:02:25,980 I will have Peter Collins. 35 00:02:26,120 --> 00:02:33,890 Now, what about this very type conversion, what we can do after the plus symbol? 36 00:02:34,160 --> 00:02:42,140 What I would always do, I will leave a space like that and I will need to concatenate again with the 37 00:02:42,140 --> 00:02:42,940 plus symbol. 38 00:02:43,220 --> 00:02:46,730 So it will be first name space last night. 39 00:02:46,940 --> 00:02:51,290 So they're all they're old now. 40 00:02:51,290 --> 00:02:56,620 Transfer or let's say not transferred is not good work. 41 00:02:56,750 --> 00:03:02,630 So they're all now considered as a sphinx because first time hold strings. 42 00:03:02,900 --> 00:03:07,900 This one is considered a space of the string and this one is a string. 43 00:03:08,060 --> 00:03:11,670 Now, we do have these old. 44 00:03:12,110 --> 00:03:20,210 So what we can do, we can just create additional work here and C plus old. 45 00:03:23,010 --> 00:03:25,260 So Peter Collins is. 46 00:03:28,160 --> 00:03:31,560 Speace plus, so we need to congratulate again. 47 00:03:31,790 --> 00:03:41,300 So now I would like to see Peter Cullen is 33 years and we can just again attach or concatenate something 48 00:03:41,300 --> 00:03:44,510 else years old like this. 49 00:03:46,320 --> 00:03:47,380 Let's check it out now. 50 00:03:47,550 --> 00:03:50,340 So Peter Collins is 33 years old. 51 00:03:50,520 --> 00:03:54,360 So what I did have I have a mixed type of variables. 52 00:03:54,480 --> 00:04:00,570 One, it's holding a number like thirty three, which hold integer number, the other one that hold 53 00:04:00,720 --> 00:04:01,260 string. 54 00:04:01,590 --> 00:04:05,270 So that is how we can join this together. 55 00:04:05,310 --> 00:04:09,620 That is how it's called type Hershon. 56 00:04:09,660 --> 00:04:14,460 Now, one more thing before we go so we can be clear. 57 00:04:16,770 --> 00:04:21,030 So remember, we declare one by one here variables we can declare. 58 00:04:24,330 --> 00:04:37,860 In one line, certain variables, first, variable, second, third and fourth right now. 59 00:04:39,740 --> 00:04:48,740 So I have this right here, so third, fourth, so I save it and now if I try to access some of them 60 00:04:48,740 --> 00:04:49,690 comes a lot. 61 00:04:51,440 --> 00:04:54,130 For example, first, not that one. 62 00:04:54,440 --> 00:04:59,980 So I will have undefined value because actually we just declared it. 63 00:05:00,530 --> 00:05:07,100 Now we can define them in the lines below or assign a value 64 00:05:09,890 --> 00:05:11,850 in the lines below. 65 00:05:12,740 --> 00:05:14,450 So what can do? 66 00:05:14,480 --> 00:05:20,770 You can say first here, I don't have to put water in order to specify if it's variable. 67 00:05:20,780 --> 00:05:24,020 I can say first I'm going to say Rick. 68 00:05:28,040 --> 00:05:36,050 Sammy Gall here, and I'm just going to copy this one couple of more times, so first and the second 69 00:05:36,320 --> 00:05:37,940 it will be Andy. 70 00:05:42,100 --> 00:05:43,210 And third, 71 00:05:46,660 --> 00:05:48,820 third will be John. 72 00:05:51,120 --> 00:05:53,980 And fourth, Melissa. 73 00:05:55,560 --> 00:06:02,760 So now if I get space, if I can, I can I mean, I can show them here. 74 00:06:03,180 --> 00:06:07,470 If I do lock first, it will give me not any more undefined. 75 00:06:07,470 --> 00:06:09,000 It will give me a ring. 76 00:06:09,180 --> 00:06:19,860 Also, if you want to do so, I'm going to say, plus your karma and I'm going to see here, OK, second, 77 00:06:20,160 --> 00:06:25,800 and that will give me first week and the second with commas in between. 78 00:06:26,100 --> 00:06:33,030 So that is how we can just declare multiple variables in one line and after that in our code below, 79 00:06:33,150 --> 00:06:34,870 we can just assign of values to them. 80 00:06:34,950 --> 00:06:36,460 That's very good, right? 81 00:06:37,320 --> 00:06:45,410 What else we can do here is we can mutate because the actual was very type coercion and notation. 82 00:06:46,200 --> 00:06:51,960 Now this is and the first and first is and second is Andy. 83 00:06:52,140 --> 00:06:57,630 But what if I change my mind and just want to put a second as a second place? 84 00:06:57,630 --> 00:06:58,380 I just want to put it. 85 00:06:58,560 --> 00:06:59,160 I don't know. 86 00:07:00,810 --> 00:07:01,290 I don't know. 87 00:07:01,560 --> 00:07:02,340 Novac. 88 00:07:03,390 --> 00:07:05,550 So you should know who's Novak? 89 00:07:05,550 --> 00:07:07,430 Is Novak Djokovic the famous tennis player? 90 00:07:07,440 --> 00:07:07,680 Right. 91 00:07:07,920 --> 00:07:18,190 So if I do it if I copy it right now, he and I should see Rick in Novak in a second place. 92 00:07:18,510 --> 00:07:18,940 Right. 93 00:07:19,140 --> 00:07:22,330 This is called variable mutation. 94 00:07:22,350 --> 00:07:24,510 So we mutate its value. 95 00:07:24,810 --> 00:07:25,140 Right. 96 00:07:25,380 --> 00:07:29,250 Because here was and now the second place, it's Novak. 97 00:07:29,400 --> 00:07:35,010 But because we are printing press here, that's why he's grabbing this value, the initial value from 98 00:07:35,010 --> 00:07:35,340 Andy. 99 00:07:35,520 --> 00:07:41,400 Now, we do have different value, and that is why we are seeing Novak here. 100 00:07:41,760 --> 00:07:42,860 So how cool is this? 101 00:07:42,900 --> 00:07:49,470 We can just changed our values as we won in our code as we need them. 102 00:07:49,680 --> 00:07:50,080 Right. 103 00:07:50,310 --> 00:07:56,690 So that is called a signing, declaring a variable, assigning a valuable in mediating. 104 00:07:57,000 --> 00:07:58,620 This is called coersion. 105 00:07:58,620 --> 00:08:05,670 When we put different types of variables with different values inside in one single go into one single 106 00:08:05,670 --> 00:08:05,960 line. 107 00:08:06,120 --> 00:08:13,500 So JavaScript is more and knows and that's not the case with other languages that, OK, I'm going to 108 00:08:13,500 --> 00:08:16,290 put them, I'm going to just treat them all as a string's. 109 00:08:17,130 --> 00:08:18,930 That's all you need to know right now. 110 00:08:19,170 --> 00:08:21,330 And I hope you enjoyed this lecture. 111 00:08:21,510 --> 00:08:25,170 And it's we're still working with variables, but it is what it is. 112 00:08:26,010 --> 00:08:27,570 So we're learning a lot every day. 113 00:08:27,570 --> 00:08:29,940 Something new, every lecture, something new. 114 00:08:29,940 --> 00:08:31,780 I hope you like bleep subscribe. 115 00:08:31,800 --> 00:08:40,770 Join me and help me out to grow anything that I do, grow my channels, grow my project, grow my courses, 116 00:08:40,980 --> 00:08:42,930 because sharing means caring. 117 00:08:42,930 --> 00:08:44,490 And I'm caring about you guys. 118 00:08:44,730 --> 00:08:45,840 You care about me. 119 00:08:45,840 --> 00:08:51,000 That is, I want to see a mutual respect and obligation and love here. 120 00:08:51,000 --> 00:08:51,930 So thank you very much. 121 00:08:51,930 --> 00:08:53,580 I hope to see you in the next one. 122 00:08:53,820 --> 00:08:55,140 And I hope you enjoyed this one.