Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP __FILE__ magic constant in JavaScript
/**
* __defineGetter__ - IE9+
* new Error - IE10+
*/
window.__defineGetter__('__FILE__', function() {
return (new Error).stack.split('/').slice(-1).join().split('.')[0];
});
console.log(__FILE__); // js_filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.