title: How to pass parameters in Javascript constructor?
body: <p>In this code block:</p>
  <ol>
  <li><p>if I declare <code>resolve / reject</code> with <code>const</code> keyword,</p>
  <p>I need to pass them into <code>executor</code> function without <code>this</code>, and using <code>this</code> will get error;</p>
  </li>
  <li><p>if I declare <code>resolve / reject</code> with <code>this</code> keyword,</p>
  <p>I need to pass them into <code>executor</code> function with <code>this</code>.</p>
  </li>
  </ol>
  <p>What cause this different behavior?</p>
  <p>And what differences between these two ways?</p>
  <p>Please help me, thanks~</p>
  <pre><code>class myPromise {
    constructor(executor) {
     
      this.status = PENDING;
      this.value = null;
      this.reason = null;
  
      const resolve = value =&gt; {
        this.value = value;
      }
  
      this.reject = reason =&gt; {
        this.reason = reason;
      }
    
      // Why not use this.resolve / this.reject ?
      // 
      executor(resolve, this.reject);
    }
  
    then(onfulfilled = Function.prototype, onrejected = Function.prototype) {
      onfulfilled(this.value);
  
      onrejected(this.reason);
    }
  }
  </code></pre>