Jump to content

JavaScript: Difference between revisions

Line 250: Line 250:


==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>