updated: 7th of April 2019
published: 5th of November 2017
// Single line comment
/*
Multiple
line
comment
*/
// Declaration
var stuff;
// Assignment
stuff = "stuff";
// Declaration and assignment
var stuff = "stuff";
"Single line string";
42;
true;
// or
false;
["stuff", "things"];
{stuff_key: "stuff_value", things_key: "things_value"};
// Iterate list
for (var i=0; i < things.length; i++) {
console.log(things[i]);
}
// Alternate syntax
for (var i in things) {
console.log(things[i]);
}
// Iterate dictionary
var i = 0;
while (i < things.length) {
console.log(things[i]);
i++;
}
if (1 > 42) {
console.log("One");
} else if (42 < 1) {
console.log("The answer");
} else {
console.log("Maths is fun");
}
function stuff() {
stuff = ["stuff", "things"];
return stuff;
}
class Stuff {
constructor(stuff) {
this.stuff = stuff;
}
set stuff(stuff) {
this._stuff;
}
get stuff() {
return this._stuff;
}
showStuff() {
console.log(this.stuff)
}
}