How can we know if a function is called from console or from source code
问题 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 check if it's from console or from the page but it works only in google chrome, it doesn't work in firefox, I didn't test other browsers function fromConsole() { var Caller = arguments.callee.caller; while(Caller.caller != null) Caller = Caller.caller; return (Caller.toString().indexOf("function (expression, objectGroup,"))!=-1; }