Javascript, get the name of a bound function -
i've created function , bound arguments below.
function myfunc(){} let boundfunc = myfunc.bind(argument);
but pass bound function argument function, need name. following:
function dothething(callable){ console.log(callable.name + " did thing"); } dothething(boundfunc);
prints out bound did thing
rather myfunc did thing
. there way name of bound function?
callable.caller
results in uncaught typeerror: 'caller' , 'arguments' restricted function properties , cannot accessed in context.
, not browser standard.
google chrome v 51.0.2704.103 gives different result:
function myfunc(){} let boundfunc = myfunc.bind(null); function dothething(callable){ console.log(callable.name + " did thing"); } dothething(boundfunc);
it prints bound myfunc did thing
, original name callable.name.substring(6)
Comments
Post a Comment