Is there a standard way to access the current script file name?
Is there some kind __FILE__, and __LINE__in C ++ , or the PHP .
__FILE__
__LINE__
If there is no standard way to do this, what tools allow you to add such functions to .js files (preprocessing)?
I am not looking for browser specific solutions (i.e. ) ReferenceError: document is not defined
ReferenceError: document is not defined
I'm not sure what you are using, but in node.js you can do it like this
file.js
var path = require("path"); console.log(path.basename(__filename)); // => file.js
There is no way to do this in the browser though.
NodeJS, __filename module.filename, .
__filename
module.filename
Yes there is __FILE__in php. You can use basename ( __FILE__, ".php") to have a file name and disable the extension if you want.