title: Why the output of the two writing methods are inconsistent？
body: <p>The first way to write：</p>
  <pre><code>    const LazyMan = function (name) {
        const array = []
        const fn = () =&gt; { console.log(&quot;Hi! This is &quot; + name + '!'); next() }
        const next = () =&gt; {
          const fn = array.shift()
          fn &amp;&amp; fn()
          // array.shift() &amp;&amp; array.shift()()
        }
        array.push(fn)
        setTimeout(() =&gt; { next() }, 0)
        const api = {
          sleep: (number) =&gt; {
            array.push(() =&gt; {
              setTimeout(() =&gt; { console.log('Wake up after ' + number); next() }, number * 1000)
            })
            return api
          },
          eat: (content) =&gt; {
            array.push(() =&gt; {
              console.log('eat ' + content); next()
            })
            return api
          },
          sleepFirst: (number) =&gt; {
            array.unshift(() =&gt; {
              setTimeout(() =&gt; { console.log('Wake up after ' + 5); next() }, number * 1000)
            })
            return api
          }
        }
        return api
      }
      LazyMan(&quot;Hank&quot;).sleep(2).eat(&quot;dinner&quot;).sleepFirst(1);
      // Wake up after 5
      // Hi! This is Hank!
      // Wake up after 2
      // eat dinner
  </code></pre>
  <p>The second way to write：</p>
  <pre><code>    const LazyMan = function (name) {
        const array = []
        const fn = () =&gt; { console.log(&quot;Hi! This is &quot; + name + '!'); next() }
        const next = () =&gt; {
          const fn = array.shift()
          // fn &amp;&amp; fn()
          array.shift() &amp;&amp; array.shift()()
        }
        array.push(fn)
        setTimeout(() =&gt; { next() }, 0)
        const api = {
          sleep: (number) =&gt; {
            array.push(() =&gt; {
              setTimeout(() =&gt; { console.log('Wake up after ' + number); next() }, number * 1000)
            })
            return api
          },
          eat: (content) =&gt; {
            array.push(() =&gt; {
              console.log('eat ' + content); next()
            })
            return api
          },
          sleepFirst: (number) =&gt; {
            array.unshift(() =&gt; {
              setTimeout(() =&gt; { console.log('Wake up after ' + number); next() }, number * 1000)
            })
            return api
          }
        }
        return api
      }
      LazyMan(&quot;Hank&quot;).sleep(2).eat(&quot;dinner&quot;).sleepFirst(1);
      // Wake up after 2
  </code></pre>
  <p>const fn = array.shift() fn &amp;&amp; fn();
  array.shift() &amp;&amp; array.shift()();</p>
  <p>The console output results of the first method and the second method are inconsistent, The second method only outputs the result of &quot;Wake up after 2&quot;, which is not what I want，I want to know why？</p>