- Help support classes/other new function definitions in legacy framework code without significant changes
- Expose a pretty important part of the runtime to applications, who also may wish to use them
- Not require depending on slow (and inconsistent across implementations)
Function.toString()
processing or try/catch statements
When the isCallable
function is called with argument argument, the following steps are taken:
- If IsCallable(argument) is false, return false.
- If argument has a [[IsClassConstructor]] internal slot with value true, return false.
- Return true.
(Should be "Return IsCallable(argument)", but adjusted to not report Class constructors as callable, as they throw unconditionally without invoking any author code)
When the isConstructor
function is called with argument argument, the following steps are taken:
- Return IsConstructor(argument).