JavaScript - Syntax : Variables Flashcards
What is a variable in programming?
A container for a value.
What does a variable provide for data in programming?
A way of labeling data with a descriptive name.
What is the first action that can happen to a variable?
Declare/Define
What does it mean to declare/define a variable?
Request a location in memory of a given size with a descriptive name.
What is the second action that can happen to a variable?
Initialise
What does initialising a variable do?
Set the location in memory to a known value.
What is the third action that can happen to a variable?
Use
What does using a variable entail?
Store or update information stored in a variable.
What is the fourth action that can happen to a variable?
Destroy
What happens when a variable is destroyed?
Remove the label on the location in memory and release the memory back to the operating system.
What keyword is used to declare a variable that is available throughout the function?
var
Where are variables declared by the ‘let’ keyword available?
Only inside the block where they’re defined.
What does the ‘const’ keyword do?
Creates a variable that cannot be reassigned after it has been assigned a value.
Fill in the blank: To create a variable that cannot be reassigned, use the _______ keyword.
const