Dynamically-typed
JavaScript is a Dynamically-typed language.
But, what is the definition of Dynamically-typed ?
For example,
1 | let a=1; |
Indeed, the real process is below, and you can use typeof
to check the type
then you will get
1 | let a; |
Means, the type of variable is decided when the value is given to that variable.
This is called Dynamically-typed.
weakly-typed
JavaScript is a weakly-typed language.
And there are two types of coercions under the weakly-typed language
- explicit coercion
example as below
1 | let a=1; |
When a variable is given another type of value, it will undergo explicit coercion.
- implicit coercion
example as below
1 | let a=1; |
This is called implicit coercion.