How to Create Variables and More in JavaScript


show more Variables are containers for data. Creating variables in JavaScript is simple once you know the right steps. Learn how create variables, name variables, assign data types with values, and use quotes to hold strings. show less
please wait ...

Creating variables

In all programs and all programming languages we have to keep track of many pieces of data, email addresses, a date of birth, position of an image on the screen, the current score in a game, so we create variables to hold that data. A variable is a container. It's us grabbing a little piece of computer memory and giving it a name, so we can use it while our JavaScript is running. We create it, we name it, we put a value in it, and then we change the value as we need to. In JavaScript, you create a variable like this.

You use the word var, all written in lowercase, which is part of the JavaScript language, and then the word you want. The name of the variable itself is up to us, and it should represent the piece of data that we want to hold, in this case year, but it could be customerEmail, or todaysDate, or while we're experimenting, just nonsense words like foo, or even single letters like x. The name that you want to use for your variable must be written as one word, no spaces are al...

Creating variables
Video duration: 6m 21s 5h 31m Beginner

Viewers:

Variables are containers for data. Creating variables in JavaScript is simple once you know the right steps. Learn how create variables, name variables, assign data types with values, and use quotes to hold strings.

Subjects:
Developer Web
Software:
JavaScript
Author:
please wait ...