In recent versions of Chrome and Firefox, this is possible as follows. I recommend this for debugging purposes only (e.g. javascript trace in non-production)
var mystery = function() {
var myNameInChrome = /.*Object\.(.*)\s\(/.exec(new Error().stack)[1];
var myNameInFF = new Error().stack.split("@")[0];
}
source
share