Last active
August 29, 2015 14:06
-
-
Save lukluk/d4b6307287187e2da8b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//luklukaha@gmail.com | |
//where.iam() >> get file path and line number where .iam() called | |
var where=new function(){ | |
this.getErrorObject=function (){ | |
try { throw Error('') } catch(err) { return err; } | |
} | |
this.iam=function(){ | |
var err = this.getErrorObject(); | |
var caller_line = err.stack.split("\n")[4]; | |
var index = caller_line.indexOf("at "); | |
var clean = caller_line.slice(index+2, caller_line.length); | |
console.log(">> you in function : "+clean); | |
} | |
} | |
//test | |
function test(){ | |
where.iam(); | |
} | |
test(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment