1
00:00:06,720 --> 00:00:07,890
In this video.

2
00:00:07,890 --> 00:00:15,390
Let's talk about console dot log, the name that we have been mentioning from the beginning of this

3
00:00:15,390 --> 00:00:15,810
course.

4
00:00:16,079 --> 00:00:24,810
At this point, until this point, you all know what console log is, but it's time to learn more about

5
00:00:24,810 --> 00:00:26,430
console log.

6
00:00:26,460 --> 00:00:28,500
So let's get rocking.

7
00:00:28,800 --> 00:00:32,400
Well, console log is a function.

8
00:00:33,170 --> 00:00:36,920
One key word here is what is a function?

9
00:00:37,670 --> 00:00:45,800
Even looking at a syntax, you see we have the square braces telling you is a function and it is used

10
00:00:45,800 --> 00:00:54,920
to print any text to the console ranging from simple text variables, objects and arrays.

11
00:00:54,950 --> 00:00:59,360
That's one key point about console.log.

12
00:00:59,780 --> 00:01:10,910
The next point about console.log is that JavaScript console were built inside browsers and it is like

13
00:01:10,910 --> 00:01:17,210
a command line interface that runs JavaScript on your JavaScript engine.

14
00:01:17,980 --> 00:01:26,140
But behind the console is what we call read ever print and loop.

15
00:01:26,470 --> 00:01:30,040
And in short, we call it repo.

16
00:01:30,830 --> 00:01:31,220
All right.

17
00:01:31,220 --> 00:01:33,740
Let's talk more about this report.

18
00:01:33,770 --> 00:01:34,220
All right.

19
00:01:34,220 --> 00:01:40,070
So let's say that we are trying to run a simple function inside the console.

20
00:01:40,250 --> 00:01:44,270
So in the first place, it reads your input.

21
00:01:44,450 --> 00:01:44,930
All right.

22
00:01:44,930 --> 00:01:51,680
And then it evaluates it as JavaScript code and then it prints the results.

23
00:01:51,860 --> 00:01:54,640
That's a work of the repo, right?

24
00:01:54,650 --> 00:02:02,150
You sometimes hear the term repo being used to refer to any sort of programming shell that allows you

25
00:02:02,150 --> 00:02:05,810
to enter code and see results immediately.

26
00:02:05,960 --> 00:02:13,400
For instance, Node.js, Python and Ruby also provide similar repo shell.

27
00:02:13,970 --> 00:02:18,070
All right, so let's get back to console.log and try something.

28
00:02:18,290 --> 00:02:26,840
Let's open our console and do some simple calculations and let's see how it works behind the scene.

29
00:02:27,410 --> 00:02:29,260
Let's try to type this.

30
00:02:29,270 --> 00:02:31,370
Let's say one plus two.

31
00:02:31,400 --> 00:02:35,930
When I hit enter, it will see that I have the result.

32
00:02:35,930 --> 00:02:36,650
Three.

33
00:02:36,680 --> 00:02:43,550
How this thing happened is because of what you call the repo built inside.

34
00:02:43,850 --> 00:02:52,760
And if you are an object developer, you also have repo inside Node.js, meaning we are running JavaScript

35
00:02:52,760 --> 00:02:59,720
on the server so the same syntax can be run inside Node.js or a Node.js environment.

36
00:02:59,750 --> 00:03:02,060
So back to Visual Studio code.

37
00:03:02,240 --> 00:03:08,810
Let's try to run a simple Node.js command, even though we haven't gone there yet, but for some demonstration

38
00:03:08,810 --> 00:03:10,690
purposes, let's try it out.

39
00:03:10,700 --> 00:03:14,930
But for this one before it works, unless we have not been installed.

40
00:03:14,930 --> 00:03:17,960
But for now, don't worry if you don't have not been installed.

41
00:03:18,080 --> 00:03:26,570
So I will go to terminal here and a new terminal and inside my terminal to be able to execute repo or

42
00:03:26,570 --> 00:03:28,550
command inside my terminal.

43
00:03:28,580 --> 00:03:36,350
I'm going to use node and now hit enter and can see that now I'm in the repo of node.js so the same

44
00:03:36,350 --> 00:03:41,160
code I type one plus two when I hit enter, you see I have three.

45
00:03:41,180 --> 00:03:46,520
This is what we call the repo and we have the same repo inside browser.

46
00:03:46,550 --> 00:03:48,860
That is our console log.

47
00:03:49,660 --> 00:03:51,700
But have a look.

48
00:03:51,700 --> 00:03:58,240
You see that when you run this code as soon as it print the answer we have next line at that mean going

49
00:03:58,240 --> 00:04:04,390
to loop through its looping but let's try to run a simple function and let's the difference here.

50
00:04:04,570 --> 00:04:06,250
Let's try to run this function.

51
00:04:06,290 --> 00:04:09,370
Remember, console.log is a function, right?

52
00:04:09,370 --> 00:04:12,850
So let's say this function will say say hi.

53
00:04:16,760 --> 00:04:18,019
Now have a look.

54
00:04:18,019 --> 00:04:21,980
When I hit enter, two things are going to happen when I hit Enter.

55
00:04:22,010 --> 00:04:24,740
First, we have the resort.

56
00:04:24,740 --> 00:04:25,850
Say hello.

57
00:04:26,090 --> 00:04:30,560
And on second line, we see what is called undefined.

58
00:04:30,800 --> 00:04:33,620
Let me explain why this happened.

59
00:04:34,010 --> 00:04:40,190
When executing a function in the console, for example, using the console log.

60
00:04:40,220 --> 00:04:46,140
This one as we did well, it produces two lines of output.

61
00:04:46,160 --> 00:04:51,470
One is the result and one is on define.

62
00:04:51,590 --> 00:04:58,010
The first line is a result that we expect and indeed this is what we are expecting.

63
00:04:58,040 --> 00:04:58,700
Okay.

64
00:04:58,970 --> 00:05:02,830
The second line reads what is called undefined.

65
00:05:02,840 --> 00:05:05,720
Why I got undefined here.

66
00:05:06,020 --> 00:05:14,420
This is because the first line is the output that we instructed JavaScript to print, and the second

67
00:05:14,420 --> 00:05:18,310
line is a result of evaluating our program.

68
00:05:18,320 --> 00:05:25,010
The second line here you are trying to evaluate our program and in short our function called console.log.

69
00:05:25,340 --> 00:05:33,680
So every JavaScript expression has a result, but some expressions such as the console.log function,

70
00:05:33,680 --> 00:05:37,820
they all return an empty result called undefined.

71
00:05:38,240 --> 00:05:45,860
So any expression that does not return an answer, the repo we give us as undefined.

72
00:05:46,100 --> 00:05:47,300
All right, so that is it.

73
00:05:47,300 --> 00:05:49,790
About the console, that log.

