Skip to content

Instantly share code, notes, and snippets.

@BR0kEN-
Created January 25, 2014 17:53
Show Gist options
  • Save BR0kEN-/8620537 to your computer and use it in GitHub Desktop.
Save BR0kEN-/8620537 to your computer and use it in GitHub Desktop.
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