title: Why javaScript's Optional Chaining Syntax does not work with Nullish Coalescing Operator when there is no method's return value?
body: <p>I&quot;m trying the new JavaScript Optional Chaining syntax and it seems that it has an issue with methods which has no return value.
  For example:</p>
  <p>I have a restaurant object with order method in it:</p>
  <pre><code>const restaurant = {
  order(i, k) {
      console.log(`I was here with ${i} and ${k}`);
     // does not return value
    }
  };
  </code></pre>
  <p>Now if i try to check if the order method exist inside restaurant object like below, it returns 'undefiend':</p>
  <pre><code>const orderCheck = restaurant.order?.(0, 1);
  console.log(orderCheck ); // it returns undefined
  </code></pre>
  <p>Now the problem is, if i use above case with Nullish Coalescing Operator like below, it does not work:</p>
  <pre><code>console.log(restaurant.order?.(0, 1) ?? 'Method does not exist');
  
  Output: 
  I was here with 0 and 1
  Method does not exist
  </code></pre>
  <p>ISSUE:
  Now the issue in above statement is, the optional chaining syntax even finds the order method &amp; prints &quot;I was here with 0 and 1&quot; but still returns 'undefiend' which makes Nullish Coalescing Operator to proceed and even it prints 'Method does not exist' too as default value?</p>
  <p>Now, if i allow the order method to return a value then it works fine with Nullish Coalescing Operator and it does not proceed.</p>
  <pre><code> const restaurant = {
      order(i, k) {
          console.log(`I was here with ${i} and ${k}`);
          return '1';
        }
      };
  </code></pre>
  <p>If check again:</p>
  <pre><code>console.log(restaurant.order?.(0, 1) ?? 'Method does not exist');
  
  Output: 
  I was here with 0 and 1
  </code></pre>
  <p>Is it necessary for optional chaining syntax to expect a return value other than nullish values from a method in order to check its availability?</p>
  <p>In above case, the order method does exist then How to prevent Nullish Coalescing Operator to not to proceed for the default 'Method does not exist'?</p>
  <p>I'm testing it with modern browsers (Chrome &amp; firfox) and i have also enabled the javaScript experimental features in Chrome but it still work the same above way.</p>
  <p>Any thoughts would be helpful? Thanks</p>