How can I determine the current line number in JavaScript?

javascript, line-numbers

Solution

`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.

UPDATE:

If you are debugging on browser you can see current line of running console.log() on right side of window under console section.

Problem

Does JavaScript have a mechanism for determining the line number of the currently executing statement (and if so, what is it)?

Original source

Related problems