Skip to content

Instantly share code, notes, and snippets.

Created January 25, 2014 17:53
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