Skip to content

Instantly share code, notes, and snippets.

@lukluk
Last active August 29, 2015 14:06
Show Gist options
  • Save lukluk/d4b6307287187e2da8b8 to your computer and use it in GitHub Desktop.
Save lukluk/d4b6307287187e2da8b8 to your computer and use it in GitHub Desktop.
//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