title: window.onload that return a function
body: <p>I tried to make a function that create a canvas with width and height how parameters. In an other file I called createCanvas(200,200), but the console give me an error:</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: createCanvas is not defined
        at main.js:1".</p>
  </blockquote>
  
  <pre class="lang-js prettyprint-override"><code>var context = undefined;
  window.onload = function() {
  
    function createCanvas(w, h) {
      var canvas = document.createElement('canvas');
  
      if (context == undefined) {
        context = canvas.getContext('2d');
  
        width = canvas.width = h || 50;
        height = canvas.height = w || 50;
        document.body.appendChild(canvas);
      };
    };
    return createCanvas();
  }
  </code></pre>