javascript get line number of error

Solutions on MaxInterview for javascript get line number of error by the best coders in the world

showing results for - "javascript get line number of error"
Regina
28 Sep 2020
1function getErrorObject(){
2    try { throw Error('') } catch(err) { return err; }
3}
4
5var err = getErrorObject();
6var caller_line = err.stack.split("\n")[4];
7var index = caller_line.indexOf("at ");
8var clean = caller_line.slice(index+2, caller_line.length);