title: Prevent Overriding Javascript Function
body: <p>I'm using a Modular Pattern in JavaScript. I wonder if we can prevent the public modules to be overridden.
  For example, in the code below <strong>function1, function2, function3 and function4</strong> can be accessed outside but I don't want to override. If these functions are overridden then I want the compiler to generate an error message</p>
  
  <pre><code>"use strict";
  
  var $ = (function(){
  return{
        function1 : function(){
            alert("this is Function1");
        },
        function2 : function(){
            alert("this is Function2");
        },
        function3 : function(){
            alert("this is Function3");
        },
        function4 : function(){
            alert("this is Function4");
        }
      };
  }());
  
  
  $.function1(); //will alert - this is Function1
  $.function2(); //will alert - this is Function2
  
  /* 
    I don't want to do this, If I do, then I want the compiler to generate an   
    error message
  */
  $.function3=function(){
      alert('function 3 is overridden');
  
  };
  $.function3(); //will alert - function 3 is overridden
  </code></pre>