is-callable icon indicating copy to clipboard operation
is-callable copied to clipboard

Missing examples

Open nickshanks opened this issue 2 years ago • 3 comments

Need new lines at the end of the README examples block:

assert.ok(isCallable(Function(''));
assert.ok(isCallable(new Function);
assert.ok(isCallable(new Function(''));
assert.ok(isCallable(new Function([], ''));

nickshanks avatar Aug 11 '23 07:08 nickshanks

Since Function should never be used, I'm not sure why it would be a good idea to include them in examples?

ljharb avatar Aug 11 '23 18:08 ljharb

To show that this function can cope when legacy code is thrown at it. Isn't that the point? You don't know if you are being passed an object that can be invoked (presumably because you don't control the other end, and it may have been written in 1996), so you need to validate it.

Feel free to annotate the above examples with a comment such as // invoking Function is deprecated but supported.

nickshanks avatar Aug 14 '23 08:08 nickshanks

I suppose that’s fair, but has there ever been an instance in any engine when a Function produced something distinguishable from a normal function? Why would anyone have any expectation that using Function changes anything?

ljharb avatar Aug 14 '23 15:08 ljharb