x = 1;
undefined
null
boolean
"number", other sort of number?
Following will run, but the typo no noticed.
myVariable = 1;
myVaraible = myVariable + 1;
We can enforce declaration of variables to help prevent this.
"use strict"
var x = 1;
x = 1;
This works, even though we may not expect it to.
{
var x = 1;
}
var y = x;
Block requires "let"
{
let x = 1;
}
var y = x;
"let" is a newer keyword than "var". Broadly "use strict" and "let" should be used throughout.
Like let (uses block scope) but can’t reassign. This increases safety and can make compiler work better.
Dynamically typed. eg can add different types of numerical stuff?
a==b
a!=b
returns boolean
if different types, converts before comparing
"1" == 1 // evaluates to true
If use \(3\) equals signs, no type conversion.
"1" === 1 evaluates to false