Best way to check if a function is related to regular JavaScript?

I am in a situation where I would like to know if a function is associated with setting a warning message when this function is called using callor applywith another context.

function myfn (){ }
/* or */
var myfn = function () {}


var ref = myfn.bind(null);

I checked the function object in Firefox and the Chrome console, and the only difference I found is that the associated version has a name with a prefix bound.

> myfn.name
> "myfn"

> ref.name
> "bound myfn"
  • Is this a reliable check?

  • Are there any other ways to find if the function is already connected?

* NOTE: Not interested in older browsers (eg: <ie10)

+4
source share
1 answer

?

. ES6, ES6, .name .

, ?

.prototype, , , , . .

+4

Source: https://habr.com/ru/post/1652755/


All Articles