title: How to determine if a function was called with `.call` or `.apply`?
body: <p>I created this function so that I could chain methods together:</p>
  
  <pre><code>export default function bindable(fn) {
      return function boundFn(...args) {
          return this === undefined ? fn(...args) : fn(this, ...args);
      }
  }
  </code></pre>
  
  <p>It works with the <a href="https://babeljs.io/docs/plugins/transform-function-bind/" rel="nofollow noreferrer">bind operator</a>. For example, you can define a new function like,</p>
  
  <pre><code> export const flatten = bindable(arrayOfArrays =&gt; Array.prototype.concat(...arrayOfArrays));
  </code></pre>
  
  <p>And then use it like this:</p>
  
  <pre><code>[[1,2,3],[4,5,6]]::flatten()
  </code></pre>
  
  <p><em>Or</em> like this:</p>
  
  <pre><code>flatten([[1,2,3],[4,5,6]])
  </code></pre>
  
  <p><a href="https://babeljs.io/repl/#?babili=false&amp;evaluate=true&amp;lineWrap=false&amp;presets=env%2Cstage-0&amp;targets=Node-8&amp;browsers=&amp;builtIns=false&amp;debug=true&amp;experimental=true&amp;loose=true&amp;spec=false&amp;code=function%20bindable(fn)%20%7B%0A%20%20%20%20return%20function%20boundFn(...args)%20%7B%0A%20%20%20%20%20%20%20%20return%20this%20!%3D%3D%20undefined%20%26%26%20args.length%20%3C%20fn.length%20%3F%20this%3A%3Afn(this%2C%20...args)%20%3A%20this%3A%3Afn(...args)%3B%0A%20%20%20%20%7D%0A%7D%0A%0Aconst%20flatten%20%3D%20bindable(arrayOfArrays%20%3D%3E%20Array.prototype.concat(...arrayOfArrays))%3B%0A%0Aconsole.log(%5B%5B1%2C2%2C3%5D%2C%5B4%2C5%2C6%5D%5D%3A%3Aflatten())%3B%0Aconsole.log(flatten(%5B%5B1%2C2%2C3%5D%2C%5B4%2C5%2C6%5D%5D))%3B" rel="nofollow noreferrer">Babel REPL</a></p>
  
  <p>This worked great at first until I realized that if I use it like in the second scenario, but import the helper method as a module, it breaks the context!</p>
  
  <pre><code> import * as Arr from './array-helper-methods';
   Arr.flatten([1,2,3]); // `this` is now `Arr`
  </code></pre>
  
  <p>So my question is: <strong>is there any way that I can reliably detect if a function is called with the bind operator?</strong></p>