I have been searching for discussions about how to specify a symbol as public or private in ECMAScript 6.
As I undertand it, a private symbol would be created using a pattern similar to the following:
var itemManager = (function() {
var items = new Symbol(/* possible string description? */);
return {
[items]: [ ],
getItems: function() {
return this[items].slice();
},
addItem: function(item) {
this[items].push(item);
}
};
})();
But how could I specify the items
symbol as public? Will public symbols be possible in ES6, or will they only be private (not show up in Object.getOwnPropertyNames
for example)? Additionally, will public symbols be enumerable by default (show up in Object.keys
)?
Could anyone please link me to relevant information?