Just how reserved are the words private and public in JavaScript

Viewed 5040

Each time I build a JS library I have this sort of concept:

(function(window,undefined){
  var LibName = function(){
    var privateAPI = {
      method: function(){}
    };
    var publicAPI = {
      publicMethod: function(){}
    };
    return publicAPI;
  }
  window.LibName = LibName;
})();

But i've always longed for just doing:

(function(window,undefined){
  var LibName = function(){
    var private = {
      method: function(){}
    };
    var public = {
      publicMethod: function(){}
    };
    return public;
  }
  window.LibName = LibName;
})();

But I've never done that because those are reserved words. Just how reserved are they? Will a browser fail? In my testing, everything seems to work, but am I missing something?

4 Answers
Related