Like Lua Javascript is a described as a “dynamic” language.
What does this mean?
It means that a variable in Javascript doesn’t have a pre-declared type like it would be in a non dynamic language like C++ or Java. These non dynamic languages are described as “strongly typed” or “statically typed” languages. This means when you declare a variable in these languages as a programmer you have to declare the type and then for the lifetime of the program that variable is always going to be that type.
Contrast Javascript with C++. In Javascript this is valid:
var MyVariable = 12211; // Now MyVariable contains a number MyVariable = "My string"; // Now MyVariable contains a string
In C++ if we tried to assign a string to a int (integer) variable the compiler would refuse to compile the code:
int MyNumber = 12211; const char* pMyString = "My String"; MyNumber = pMyString; // NOT ALLOWED!!!!!!!
Being a dynamic language has its positives and negatives. It usually results in less and simpler code. But if we make a mistake and pass a number to a function which is expecting a string then we will only hear about the problem when the code is running.