is-callable
is-callable copied to clipboard
Missing examples
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([], ''));
Since Function should never be used, I'm not sure why it would be a good idea to include them in examples?
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.
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?