__LINE__ equivalent in Javascript

前端 未结 7 1563
野趣味
野趣味 2021-01-01 19:14

Is there any way to get the source line number in Javascript, like __LINE__ for C or PHP?

7条回答
  •  遥遥无期
    2021-01-01 19:51

    You can try to run C preprocessor (f.e. cpp from GNU Compiler Collection) on your javascript files -- either dynamically with each request or statically, by making this operation be applied every time you change your javascript files. I think the javascript syntax is similar enough for this to work.

    Then you'd have all the power of C preprocessor.

提交回复
热议问题