From the course: Introduction to Career Skills in Software Development

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Exploring variables across languages

Exploring variables across languages

- [Instructor] Depending on the programming language you're working with, variables can behave differently. Some languages require that you define your variables and their types before using them, like Java, C#, and C++. For example, if we want to store a user's age in Java, we would have to first declare that it will be of type int and then give our variable a name, age. We get 37 as our output when we run this code. Now let's compare this to a more relaxed language, like JavaScript. We don't need to declare a variable's type with JavaScript before using it. Here we declare the variable and use it at the same time, but I'd like you to notice a couple of things. First, we provide the name, not the type of the variable. And we use a keyword const to represent that once we get this value, we don't want it to change. When we run this code, the JavaScript interpreter can figure out the type based on our value. There are pros and…

Contents