isConstructorLike
Test if a value looks like a constructor function.
isConstructorLike(func)
Return true
if func
is a function and has a non-empty prototype, or implements
@@can.new
; false
otherwise.
canReflect.isConstructorLike(function() {}); // -> false
function Construct() {}
Construct.prototype = { foo: "bar" };
canReflect.isConstructorLike(Construct); // -> true
canReflect.isConstructorLike({}); // -> false
!!canReflect.isConstructorLike({ [canSymbol.for("can.new")]: function() {} }); // -> true
Parameters
- func
{*}
:maybe a function
Returns
{Boolean}
:
true
if a constructor; false
if otherwise.