0

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?

Nathan Wall
  • 9,698
  • 3
  • 22
  • 47

1 Answers1

4

Neither non-private names and their semantics, nor the precise syntactic support for names in general is quite settled yet. So there is nothing to link you to just yet. The best you can get is digging for the relevant threads on es-discuss.

Andreas Rossberg
  • 31,309
  • 3
  • 55
  • 70