Hey everyone!
Today i'll just be posting a few things about java script that i learnt last week.
Starting off with the variable name syntax;
Naming a variable on java script is quite different from python.
Java script involves the use of the key words: let, **
** or var.
These keywords however have slight differences apart from their names of course!
The let keyword allows you to change values while the const does not. **var **is similar to let but is an older method and is not in use anymore.
Syntax is;
let name of variable = value;
const name of variable = value;
var name of variable = value;
For example:
let nameOfCat = "Fred";nameOfCat
'Fred'nameOfCat = "Sam";
The value of the variable can be changed:
nameOfCat'Sam'
For const however, the value of the variable cannot be changed!
const nameOfCat = "Fred";nameOfCat
FrednameOfCat = "Sam"; XXXX (This will show a type error because the constant variable cannot be reassigned)
Note: When naming variables on java script, camel case is most preferred e.g nameOfCar rather than snake case (name_of_car) which is preferred in python.
That's all for today, see you in my next blog post!
Top comments (0)