https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals
*starting in 2000 with JavaScript 1.5
count = 10;
innerColor = "red";
$thing1
_thing2
hello-fish
1fish
2fish
~fish
!fish
#fish
@fish
%fish
^fish
&fish
*fish
-fish
etc. (which is also bad)
a.k.a. "literal notation"
var airplane = {
make: "Cessna",
model: "Turbo Stationair",
"tail number": "N4835F"
};
> airplane.make;
'Cessna'
> airplane["tail number"];
'N4835F'
> var airplane = {
make: "Cessna",
model: "Turbo Stationair",
"tail number": "N4835F"
};
> airplane.make;
'Cessna'
> airplane["tail number"];
'N4835F'
a.k.a. "constructors"
> function Airplane (make, model, tailNumber) {
this.make = make;
this.model = model;
this.tailNumber = tailNumber;
}
> var betsy = new Airplane('Cessna', 'Stationaire', 'N4835F');
> betsy.make;
'Cessna'
> betsy.tailNumber];
'N4835F'
> function Airplane (make, model, tailNumber) {
if(!(this instanceof Airplane)) {
return new Airplane(make, model, tailNumber);
}
this.make = make;
this.model = model;
this.tailNumber = tailNumber;
}
> var betsy = new Airplane('Cessna', 'Stationaire', 'N4835F');
> betsy.make;
'Cessna'
> betsy.tailNumber;
'N4835F'