JavaScript: Difference between revisions

(2 intermediate revisions by the same user not shown)
Line 180: Line 180:


===Map===
===Map===
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map Reference]
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map MDN Map]
[https://www.ecma-international.org/ecma-262/10.0/index.html#sec-map-objects ES2019 (ES10) Map Specification] 
This is your typical hashmap.
 
<syntaxhighlight lang="js">
<syntaxhighlight lang="js">
let myMap = new Map();
let myMap = new Map();
Line 250: Line 253:


==Modules==
==Modules==
These days, we can use modules for everything.
===Getting Started===
===Getting Started===
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules MDN Guide to Modules]<br>
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules MDN Guide to Modules]<br>
Example Module
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// Import three.js as a module. webpack will resolve this.
import * as THREE from 'three';
// Import MyClass as a module. webpack will resolve this.
import MyClass from "./MyClass.js";


// Pretend we're writing another class
export default class MyOtherClass {
  constructor() {}
}
</syntaxhighlight>
</syntaxhighlight>