How can I determine the current line number in JavaScript?

var thisline = new Error().lineNumber

If that doesn’t work in whatever environment you’re using, you can try:

var stack = new Error().stack

Then hunt through the stack for the line number.

Leave a Comment