Javascript basic commands
1. What are variables in JavaScript
- A variable is something used to store and manage data within a specific program. They are basically named containers that hold values which will be used within the html page. Numbers, strings, objects, or functions are common examples of variables.
2. What does it mean to declare a variable
- Declaring a variable means creating a new container with a specific name. This variable tells Javascript to store data in its memory with the new container. Typical variable declarations can use the keywords
var, let, or const. This command would generally look like this, let age; with age representing a newly declared variable.
3. What is an “assignment” operator, and what does it do
- Simply put an assignment operator is used to assign a value to a variable. Assignment operators take the value on the right side, separated by an
= sign, and apply it to the variable on its left. This command would look like this, let age; age = 20.
- Information recieved from the user is called user input or user data. Oftentimes this is gathered with the
prompt() function to get information from the user. Once this info is entered, it can then be used for many purposes within a program. If the prompt function was used it would look like this, let username = prompt("Enter your name here");.