head.daveops.net

Snippets for yer computer needs

JavaScript

Strict Mode

'use strict'

MDN Strict Mode docs

Classes

function Building(x,y,z) {
  this.x = x;
  this.y = y;
  this.z = z;
}

Building.prototype.area = function () {
  return x * y * z;
}

var house = Building(20,20,10);

ES6 Modules

<script type="module">
import * as FOO from './lib/foo.js';
import { baz, bax } from './lib/bar.js';
// ...
</script>

All modules are parsed with strict mode

MDN Modules

var vs. let

Use let, since it limits the scope to the block. const is also block-scoped.

TODO

http://2017.js13kgames.com/