title: Determine if argument is a class (A+ promise implementation) or a callable function
body: <p>I have a function which expects a single argument of either a function or a class and I have to do different action for each of the two.</p>
  
  <p>Example pseudocode:</p>
  
  <pre><code>function myFunction(callback) {
      if ( /* callback is a Promise class */ ) {
          return new callback(function (resolve, reject) {
              // logic
              resolve();
          });
      } else if ( /* callback is a callable function */ ) {
          // logic
          callback(); // Realistically this would not be called at the end of logic block.
      } else {
          // throw error
      }
  }
  </code></pre>
  
  <p>I'd like to offer support for arbitrary Promise library implementing the A+ standard, so the developer can pass whatever implementation they're already using and do not have to perform any workarounds or use my implementation. Keep in mind that I'm not talking just about the native implementations in modern VMs, but am also targeting <a href="https://github.com/promises-aplus/promises-spec/blob/master/implementations.md" rel="nofollow">other implementations</a>.  The callable function option is there as a fallback if developer doesn't (want to) use Promise library. I hope this explanation makes some sense. </p>
  
  <p>From what I've tried I always get same result for both the class and callable function since classes in JavaScript are just functions. The only workaround I was able to do is check <code>callback.length</code>, but this functionality is very fragile and will most likely break in any real use case. </p>