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?
https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words
and
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf for the official specification.
They’re listed in 7.6.1.2 as “reserved for future use”.