title: JavaScript: uncaught reference error: erik is not defined
body: <p>I'm writing a small utility that would make my working with canvas easier. But, when I run the code, I get the errors <code>Uncaught SyntaxError: Unexpected token = (erik.core.js:5)</code>
   and <code>Uncaught ReferenceError: erik is not defined (test.html:14(
  (anonymous function)</code>.</p>
  
  <p>Here is my HTML Code :</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;ErikJs Unit Testing&lt;/title&gt;
      &lt;script src="erik.core.js"&gt;&lt;/script&gt;
      ...
  &lt;/head&gt;
  &lt;body&gt;
      ...
      &lt;canvas id="myCanvas" width="500" height="400"&gt;&lt;/canvas&gt;
  
      &lt;script&gt;
      var ctx = erik.initCanvas("#myCanvas");
  
          ctx.beginPath();
          ctx.moveTo(100, 200);
          ctx.lineTo(200, 300);
          ctx.stroke();
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the JavaScript (erik.core.js) :</p>
  
  <pre><code>var Erik = function () {    
      this.author = "Erik Royall";
  };
  
  Erik.prototype.initCanvas = function ( element, y = '2d' ) {
      this.canvas = document.querySelectorAll( element );
      this.context = canvas.getContext( y );
      return this.context;
  };
  
  var erik = new Erik();
  </code></pre>