I want to know if there is a way to check if a javascript function is being called from console of the browser or from source code.
I defined a function that can ch
For Chrome, you could just check to see if the keys function is available. It's part of chrome's Command Line API and only available when the code was executed from the console
function myFunction() {
var fromConsole = typeof keys === 'function' && keys.toString().indexOf('Command Line API') !== -1
if (fromConsole) {
alert('From console')
} else {
alert('Not from console')
}
}