DEV Community

Seonyoung Chloe (she/they)
Seonyoung Chloe (she/they)

Posted on

1 1

31 : Why is JavaScript considered as a dynamic programming language?

Dynamic - because of what you see on paper when you analyze the code, is most likely not what you’re going to get when the program runs.

JavaScript allows you to declare (for example) variables whose value (and kind) will only be known at run-time based on conditions “on the ground”.

In contrast, static languages will not compile into runnable code unless all values (or value types) are known upfront.


Here’s a quick JavaScript example of what makes it a dynamic language:

var thisIsAString = 'I am a string';
thisIsAString = 1; // assign an integer to thisIsAString
console.log(thisIsAString); // logs 1 to the console

The variable ‘thisIsAString’ began its life as a string,
but then I switched it to an integer.

If you pull up the console on your browser
(hitting F12 should do it in most browers),
you’ll notice that the code runs just fine
even though I changed the variable’s type during program execution.

Being able to change the underlying type of a variable while the program is running without causing an error is what makes JavaScript a dynamic language.

This behavior comes with both benefits and drawbacks, so I would encourage you to keep learning more about programming languages in order to understand the differences!

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series