title: How to disable JavaScript function calls from the browser console?
body: <p>I'm working on a web application in HTML/JavaScript, and I want to prevent users from calling functions in their browser console in order to avoid cheating. All these functions are contained in a unique file called <code>functions.js</code> which is loaded in the head of the <code>index.html</code> file.</p>
  
  <p>After a search on the web I found this solution, which works fine in Google Chrome, but it is inefficient in other browsers such as Firefox:</p>
  
  <pre><code>var _z = console;
  Object.defineProperty( window, "console", {
      get : function(){if( _z._commandLineAPI ){ throw "Script execution not permitted" } return _z; },
      set : function(val){ _z = val }
  });
  </code></pre>
  
  <p>Is there a general way to disable functions call from console? Does it depend on the browser or is it just a problem of scoping or maybe something else that I have ignored?</p>