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

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