Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
WEBVTT
1
00:00:00.000 --> 00:00:04.000
One thing that separates JavaScript
2
00:00:04.000 --> 00:00:08.000
from a lot of programming languages, is that JavaScript is a dynamic
3
00:00:08.000 --> 00:00:12.000
language. What do I mean by dynamic? Well,
4
00:00:12.000 --> 00:00:16.000
we have two types of programming languages. Static languages or
5
00:00:16.000 --> 00:00:20.000
dynamic languages. In static languages, when we declare a
6
00:00:20.000 --> 00:00:24.000
variable, the type of the variable is set and it cannot be changed
7
00:00:24.000 --> 00:00:28.000
in the future. In a dynamic language like JavaScript,
8
00:00:28.000 --> 00:00:32.000
the type of a variable can change at run time. Let's see this
9
00:00:32.000 --> 00:00:36.000
in code. So back in the example from the last lecture we have declared
10
00:00:36.000 --> 00:00:40.000
this name variable, and we have set that to a string, so
11
00:00:40.000 --> 00:00:44.000
the type of name is currently a string, but it can change in the future.
12
00:00:44.000 --> 00:00:48.000
Let's take a look. So here in the console, we can execute some JavaScript
13
00:00:48.000 --> 00:00:52.000
code, we have this type of operator,
14
00:00:52.000 --> 00:00:56.000
and with that we can check the type of a variable. So after that
15
00:00:56.000 --> 00:01:00.000
we add the name of the variable. In this case the name variable
16
00:01:00.000 --> 00:01:04.000
So note that the type of name is a string. So,
17
00:01:04.000 --> 00:01:08.000
if you reassign name to a different value, like a number,
18
00:01:08.000 --> 00:01:12.000
and check it's type,
19
00:01:12.000 --> 00:01:16.000
look, the type is now changed to a number, this is what we call
20
00:01:16.000 --> 00:01:20.000
a dynamic language, so unlike static languages the type of
21
00:01:20.000 --> 00:01:24.000
these variables will be determined at runtime based on the values
22
00:01:24.000 --> 00:01:28.000
that we assigned to them. Now, let's take a look at a few more examples of the type
23
00:01:28.000 --> 00:01:32.000
of operator. And by the way, note that type of is
24
00:01:32.000 --> 00:01:36.000
another reserved keyword, so we cannot have a variable called
25
00:01:36.000 --> 00:01:40.000
type of. So, we can clear the console by
26
00:01:40.000 --> 00:01:44.000
pressing control and L. So now let's take a look at
27
00:01:44.000 --> 00:01:48.000
the type of age, it's a number. Now if we change
28
00:01:48.000 --> 00:01:52.000
age to a floating point number, and I know it doesn't make sense, but
29
00:01:52.000 --> 00:01:56.000
let's just stick to this for example, 30.1,
30
00:01:56.000 --> 00:02:00.000
and then look at type of age, it's still a
31
00:02:00.000 --> 00:02:04.000
number. So in JavaScript, unlike other programming languages
32
00:02:04.000 --> 00:02:08.000
we don't have two kinds of numbers, we don't have floating point numbers
33
00:02:08.000 --> 00:02:12.000
and integers, all numbers are of type number.
34
00:02:12.000 --> 00:02:16.000
Now, let's look at the type of is approved, it's a
35
00:02:16.000 --> 00:02:20.000
boolean as I told you before, what about the first name, let's have a
36
00:02:20.000 --> 00:02:24.000
look. Type of, first name. It's undefined.
37
00:02:24.000 --> 00:02:28.000
And that's funny, because the value of this variable is undefined
38
00:02:28.000 --> 00:02:32.000
but it's type is also undefined. What does this mean?
39
00:02:32.000 --> 00:02:36.000
Well, earlier I told you that we had two categories of types,
40
00:02:36.000 --> 00:02:40.000
we have primitives or value types, and reference types.
41
00:02:40.000 --> 00:02:44.000
In the primitive types category, we have strings, numbers,
42
00:02:44.000 --> 00:02:48.000
booleans undefined and null. So undefined
43
00:02:48.000 --> 00:02:52.000
is actually a type, but it's also a value.
44
00:02:52.000 --> 00:02:56.000
In this example, because we have set first name,
45
00:02:56.000 --> 00:03:00.000
to undefined as a value it's type is also
46
00:03:00.000 --> 00:03:04.000
undefined, okay? But what about selected color.
47
00:03:04.000 --> 00:03:08.000
Let's have a look, so type of selected color.
48
00:03:08.000 --> 00:03:12.000
The type of this variable is an object.
49
00:03:12.000 --> 00:03:16.000
What is an object? That's a topic for the next lecture.
4375
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.