1
00:00:00,300 --> 00:00:07,170
In this video we will talk about JavaScript expression and statement.

2
00:00:07,200 --> 00:00:15,360
We are moving away from normal react to normal JavaScript because understanding expression and statement

3
00:00:15,360 --> 00:00:18,210
in react is really very important.

4
00:00:18,630 --> 00:00:19,560
Okay, cool.

5
00:00:19,590 --> 00:00:26,240
So you can see that all what we are learning is adding more things to a component.

6
00:00:26,250 --> 00:00:30,390
Now we've added gsx to a component in this video.

7
00:00:30,390 --> 00:00:34,800
We will talk about also how you can add expression to your component.

8
00:00:34,800 --> 00:00:37,100
So let's go ahead and do more.

9
00:00:37,110 --> 00:00:40,170
What is expression and statements?

10
00:00:40,350 --> 00:00:47,970
So we are going to write normal JavaScript file on this component because React is JavaScript, right?

11
00:00:47,970 --> 00:00:54,750
So we can write valid JavaScript file here, whether inside my function here or outside here.

12
00:00:55,590 --> 00:00:57,350
Are we all to go?

13
00:00:57,780 --> 00:00:58,780
So try it out.

14
00:00:58,800 --> 00:01:06,420
Let's try to elect something and see if it be called normal JavaScript API elect and indeed it has been

15
00:01:06,420 --> 00:01:07,830
elected like that.

16
00:01:07,830 --> 00:01:12,300
So now I can see that I can write normal JavaScript here.

17
00:01:12,420 --> 00:01:13,680
So back to business.

18
00:01:13,680 --> 00:01:14,850
Have some space here.

19
00:01:15,180 --> 00:01:17,130
So differences.

20
00:01:18,590 --> 00:01:20,000
Between.

21
00:01:20,900 --> 00:01:23,750
Expression and.

22
00:01:25,060 --> 00:01:26,020
Statement.

23
00:01:27,490 --> 00:01:31,100
All right, so let's define it in JavaScript.

24
00:01:31,120 --> 00:01:37,750
There are two key ways to create a code, whether expression or statement.

25
00:01:38,200 --> 00:01:41,310
Each has its own purpose and syntax.

26
00:01:41,320 --> 00:01:43,060
Well, two differences.

27
00:01:43,090 --> 00:01:43,870
Here we go.

28
00:01:44,860 --> 00:01:50,920
An expression is a piece of code that produces a value.

29
00:01:51,280 --> 00:01:52,240
Simple.

30
00:01:52,980 --> 00:01:56,520
A piece of code that produces a value.

31
00:01:56,610 --> 00:02:04,830
It can be a single value, like a number or string, or it can be more complex, like an array or object.

32
00:02:05,070 --> 00:02:11,400
And expressions, on the other hand, are often used in assignment.

33
00:02:11,850 --> 00:02:16,920
Okay, so let's have a look at the example of statement.

34
00:02:16,920 --> 00:02:18,600
Remember, sorry, expression.

35
00:02:19,080 --> 00:02:23,270
Expression again produces what a value.

36
00:02:23,280 --> 00:02:33,780
So let's say that if I say let's age is equal to 42, this is expression because it's true.

37
00:02:33,780 --> 00:02:38,010
This is what a value if I console.log h.

38
00:02:38,900 --> 00:02:40,250
Let's check our terminal.

39
00:02:40,280 --> 00:02:41,330
Our browser here.

40
00:02:41,360 --> 00:02:42,230
Console.

41
00:02:42,260 --> 00:02:43,220
Open it.

42
00:02:43,430 --> 00:02:45,410
And now let's have a look.

43
00:02:45,710 --> 00:02:46,910
I have.

44
00:02:47,760 --> 00:02:50,760
I have the refresh refreshed.

45
00:02:50,850 --> 00:02:53,880
I have 42 being console.log.

46
00:02:53,910 --> 00:02:57,120
So this is what is called expression.

47
00:02:57,420 --> 00:03:02,880
And I can write, let's say I mean const.

48
00:03:04,240 --> 00:03:09,760
Sum is equal to two plus two plus two.

49
00:03:10,210 --> 00:03:17,080
This is what this what you call expression, because it's this is what a single value or I can produce

50
00:03:17,080 --> 00:03:22,240
an array of numbers is also what a expression.

51
00:03:22,630 --> 00:03:25,150
So what is a statement?

52
00:03:26,400 --> 00:03:33,870
A statement is a piece of code that does not produces a value statement, are used to create blocks

53
00:03:33,870 --> 00:03:37,020
of code like if statements or for loop.

54
00:03:37,470 --> 00:03:41,130
So let me create example of statements here.

55
00:03:42,520 --> 00:03:44,680
So a statement here is that.

56
00:03:44,770 --> 00:03:49,510
So let's declare a value for money.

57
00:03:49,750 --> 00:03:53,200
Let's say it's equal to $20 here.

58
00:03:54,100 --> 00:03:55,630
And now let's check.

59
00:03:55,630 --> 00:03:56,800
So if.

60
00:03:57,500 --> 00:04:01,250
The money you have is less than 100.

61
00:04:01,990 --> 00:04:08,470
Then we can console, look something and say that you are broke.

62
00:04:11,490 --> 00:04:12,030
Okay.

63
00:04:12,030 --> 00:04:14,520
So let's see if I check the terminal.

64
00:04:14,550 --> 00:04:16,089
Indeed I have.

65
00:04:16,110 --> 00:04:17,339
You are blocked.

66
00:04:17,540 --> 00:04:19,070
Okay, I forgot D.

67
00:04:20,130 --> 00:04:20,310
Okay.

68
00:04:20,399 --> 00:04:21,430
Don't worry about it, grandma.

69
00:04:21,450 --> 00:04:21,839
Here.

70
00:04:22,200 --> 00:04:23,490
So that is statement.

71
00:04:23,490 --> 00:04:26,280
You can see that a statement is.

72
00:04:26,310 --> 00:04:29,220
Is used to create a blocks of code like this one.

73
00:04:29,640 --> 00:04:30,150
Right.

74
00:04:30,150 --> 00:04:38,910
It checks is often used with if statement and you talk about itinerary or operator here and I mean react,

75
00:04:38,910 --> 00:04:45,120
which is crucial crucial crucial for you to understand about ternary operator here the takeaway here

76
00:04:45,120 --> 00:04:52,860
is understand how X sorry the difference between expression and I mean statement.

77
00:04:52,860 --> 00:05:00,030
The next video you talk about how we can embed expressions in js x.

