What is Javascript?
JavaScript, JS is well known as scripting language for Web pages.
Many server and desktop program also use JavaScript.
It is an object oriented programming language which is designed to make the web development easy and very attractive. It is Used with HTML and CSS and is very important tool for any web developer.
So Why Do you think that Javascript is called as a Dynamic Language?
Consider the example shown below:
Here I assign the 'Peter' for the variable called 'name'
let name='Peter';
In the browser Chrome Console, if you enter typeof(name), you will get the type shown as String as shown below:
Later If I assign a value 1 for name
name=1;
console.log(name); //this will return a value 1
Now in the browser console, if you enter typeof (name), you will get the type shown as "number".
Consider one more example :
let age=30;
Now in the console, if you enter- typeof name,
you will get the type shown as "number".
Later if you assign age with some floating point number
Eg: age=30.1;
Still typeof(age) , you will get as "number".
Unlike other programming languages, in javascript we dont have 2 types of numbers- floating and integers.
That is why we say that javascript is a dynamic language.
Unlike static languages, the type of the variables can be determined at runtime based on the values that is assigned to them.
Hopefully now it is clear that why Javascript is called a Dynamic language.
Any Suggestions are always welcome. :)
Comments
Post a Comment