Dynamically and Statically Typed Languages

From the JavaScript you have written, you have seen that when you create a new variable, you don’t have to tell JavaScript what type of data that variable is going to store. JavaScript just figures it out because JavaScript is a dynamically typed language; data types are assigned dynamically when the program runs. As you are writing your code, you don’t have to think about what data types to use because the runtime figures that out for you. Shoot first, ask questions later. This Wild West approach lets you do crazy things such as add a string and a number together to get a string (see Listing 5.1).

On the other hand, statically typed languages require that you declare a data type as you declare new variables. ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.