Reputation: 735
Is there a way to distinguish javascript code that belongs to a website and javascript code that is run from the Console tab in Chrome DevTools?
What I'm trying to do is the following:
Initialize a DEBUG
variable to true
when I copy paste my javascript code to the Console and false
when the javascript code is either located in a <script>
tag inside the html file or downloaded from the browser as in an external .js
file.
Upvotes: 1
Views: 47
Reputation: 4017
The console has a few global functions. You can do:
var DEBUG = typeof clear === 'function'; // clear() is a global in the console to clear the screen
Just make sure you don't define a global variable clear
.
Upvotes: 1