title: javascript typeError: cannot read property of undefined
body: <p>I'm attempting to create a stack class in Javascript, but I keep getting variations of the above error. I know that it is the constructor, but I just can't find where the problem is. Here's my class:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>"use strict"
  
  class Stack {
      constuctor() {
          this.items = [];
      }
  
      emptyArray() {
          if (this.items === 0) {
              this.error = "The stack is empty";
          }
          return this.error;
      }
  
      isEmpty() {
          return this.items === 0;
      }
  
      push(x) {
          return this.items.push(x);
      }
  
      pop() {
          if (this.items &gt;= 1) {
              return this.items.pop();
          }
          else {
              throw new emptyArray();
          }
      }
  
      size() {
          return this.items.length;
      }
  
      peak() {
          let el1 = this.items.pop();
          let el2 = this.items.pop();
          this.items.push(el2);
          this.items.push(el1);
          return el2;
      }
  }
  
  new Stack().size();</code></pre>
  </div>
  </div>
  </p>