getFuncionName()
by LeeMellinger
HTML
<div id="console-log"><h3>Output:</h3></div>
CSS
.console-line
{
font-family: monospace;
margin: 2px;
}
TypeScript
let consoleLine = "<p class=\"console-line\"></p>";
namespace console {
export function log (text) {
$("#console-log").append($(consoleLine).html(text));
}
}
test1();
function test1() {
console.log(getCurrentFunctionName(arguments));
log(arguments);
);
function log(arguments) {
console.log(typeof(arguments));
console.log(getCurrentFunctionName(arguments));
};
function getCurrentFunctionName(arguments: any) {
let name = arguments.callee.toString();
name = name.substr('function '.length);
return name.substr(0, name.indexOf('('));
}