Declaring a Variable Flashcards
(31 cards)
What is Syntax?
Syntax is the name given to rules that determine how a code should be written.
What is a Variable Declaration?
A Variable Declaration is the creation of a label in order to name data.
What is Initialization?
Initialization is the process of giving a value, or data, to the label (variable declaration)
What is the most common way to create a variable in JavaScript?
The most common way to create a variable in javascript is to declare it with a name and to then initialise it with a value in one line.
What is const?
const is a keyword used for beginning a declaration.
Where is the string value in the code const greeting = ‘hello there!’
The string value is ‘hello there!’
Which part of const greeting = ‘hello there!’ reflects the process of initialisation?
‘hello there!’ reflects the process of initialisation.
Which part of const greeting = ‘hello there!’ is known as the Variable?
greeting is known as the variable
Which part of const greeting = ‘hello there!’ reflects the process of declaration?
const reflects the process of declaration
What is another way of saying “initalise the value”
“assign the value” is another way of saying “initalise the value”
Which symbol is the assignment operator?
The “=” symbol is the assignment operator.
Which character in const greeting = ‘hello there!’ is the assignment operator?
The “=” is the assignment operator.
What are Keywords/Reserved Words in JavaScript?
Keywords/Reserved Words refer to certain words in Javascript that have a special meaning and therefore can’t be used as names for variables.
What is an example of a Reserved Word in JavaScript?
const
What is a Variable?
A named storage location for the storing of data.
What else can the assignment symbol be used for other than to initialise a variable?
The assignment symbol can also be used for Reassigning a new value / new values to a variable.
In the code - let greeting =’hello’; greeting=’hola’; - which greeting will be displayed on the website?
‘hola’ will be the greeting displayed on the website because ‘hello’ has been reassigned ‘hola’
Which keyword allows the value of a variable to be reassigned?
The keyword ‘let’ allows the values of a variable to be reassigned.
Does const allow you to reassign the values of a variable?
No, const does not allow you to reassign values to the variable.
What does const tell the program?
const tells the program that the values of the variable are not allowed to be changed.
Why will ‘salut’ not be shown as a greeting in the code - const greeting = ‘hola’; greeting=’salut’;
‘Salut’ will not be shown on the website because the greeting=’salut’; code will not run as a result of the keyword being used to declare the variable being ‘const’ instead of ‘let.’
What is the ‘var’ keyword in JavaScript?
The ‘var’ keyword in JavaScript is an older version of the ‘const’ and ‘let’ syntax.
What is a Convention?
Convention is a commonly-agreed upon way of writing code that helps maintain consistency and readability among developers.
What is the Convention in JavaScript when naming variables?
The convention in javascript when naming variables is to use camelCase.