JavaScript (JS) is a scripting langue used on websites and other non-browser applications.
Its important to note that JavaScript is not the same as Java
Variables are containers used to store data.
When we delcare a variable, we are telling the computer that we have a container that we will be using to store things. The 4 ways we declare variables in JavaScript are:
var
: var a = 1
- Same as let
but this is used if we want our code to run in browsers (2015 and older)let
: let a = 1
- We use let
for variables that can changeconst
: const a = 1
- Use const
on variables that cannot be changeda = 1
The assignment operator assigns a value to the variable.
You can find examples of JS Assignments here.
Information received from the user is called the input. a couple of ways to get input include the prompt()
which asks for users to type stuff into a textbox and confirm()
which asks a user to confirm (returns a value true
or cancel which returns a value of false
).