6. Dynamic vs Weakly Typed Languages in JavaScript | Complete JavaScript Tutorials

  • 4 years ago
Javascript is a dynamic interpreted programming language but it's also a weekly typed programming language.
Now what does this mean.
For one the dynamic interpreted part as you learn means that it's not pre compiled other languages like
C++ are compiled during or after development.
So before you shared them with the end users javascript is on the fly compiled and that means that the
code is evaluated and executed at runtime.
It also means that the code can change at runtime.
No of course not the code you wrote it won't magically change of course the code you wrote gets executed.
But in that code you can do some things which you are not allowed to do in other programming languages.
For example if you're working with a variable something we will only learn in the second module.
For now you can just keep in mind that a variable is a data container.
You might store let's say some text in their text you need in your script to for example output it to
the user in JavaScript you are allowed to dynamically switch to type of data there in a variable you
might start by storing some text and suddenly at a later point of time you store a number in there instead
in the same variable.
Now again we haven't really learned about variables yet.
We will of course do that but the one thing you can simply keep in mind is that the dynamic thing in
JavaScript means that it is parsed and interpreted and compiled at runtime and that therefore it is
able to do certain things.
For example switching the data off a variable over programming languages are not allowed to do.
Now it's not necessarily good to switch the type of data dynamically were unexpectedly but you can do
that.
The main takeaway however is that on the fly compilation and interpretation now what about the weakly
typed part here.
This means that when we work with data in JavaScript for example text data were numbers you don't have
to tell javascript that you're going to work with a text now or you're going to work with a number now
instead.
Data types are assumed are inferred automatic

Recommended