- One of the key ways that you'll store information
in computer programming is variables.
They allow us to make information more readable
and reusable.
Think of variables like a label on a box.
It gives an easy shorthand way of knowing
what's inside the box.
Variables can point to a number of built-in data types.
Data types are exactly what they sound like,
different ways that the programming language
stores different information.
Because you can perform different operations
on different data types,
think adding two numbers versus concatenating two strings,
programming languages need to be able
to differentiate between them.
Variables in Python are easy to declare.
You simply write the name of your variable
followed by an equal sign.
Both Python and JavaScript have dynamic typing,
meaning you don't need to tell the languages ahead of time
what data type you're storing.
Variables in JavaScript have
a slightly more complicated history.
For a long time, the way that you declared variables
in JavaScript was using the var keyword.
In 2015, there was a major new release of JavaScript
referred to as ES6 or ES2015.
This introduced a new way of declaring variables
in JavaScript, using the keyword const or the keyword let.
Let and const are replacements for var.
So for new applications, you should have no need to use var,
but you may still see old code or examples that use var.
The difference between let and const is
that const cannot be reassigned.
It is meant to be used for constants
that do not change their value for the life of the variable.
Again, with variables and data types,
you'll see a lot of similarities and complementary behavior
with JavaScript and Python.
Go ahead and play around with assigning numbers,
and maybe even see if you can figure out
how to do some math problems.
The best way to learn a programming language is
to just start coding.