Proposal About Private Symbol

Domenic Denicola d at
Sat Dec 20 18:58:15 PST 2014

Did you read the linked post? The problem is completely different from the one you describe. It is about interoperability with membranes.
From: Gary Guo<mailto:nbdd0121 at>
Sent: ‎2014-‎12-‎20 21:41
To: es-discuss at<mailto:es-discuss at>
Subject: RE: Proposal About Private Symbol

Oops, seems ruins my email. One more time

I don't think it's a problem though. As long as the private Symbol doesn't leak, there is no way to access private properties. Private Symbol as I supposed only eliminate itself from getOwnPropertySymbols, and that's it, there should not be no more constraints on private Symbol.

var constructor=function(){
    var privateField=Symbol('private', true);
    var pubField=Symbol('public');
    var leakedField=Symbol('leak', true);
    return function something(arg){
var arg="A";
var instance=new constructor(arg); // there is no way to access private fields
arg===instance[Object.getOwnPropertySymbols()[0]] // True, since Object.getOwnPropertySymbols expose the symbol
arg===instance[instance.leak]; // True, since instance.leak expose the symbol

Under careful use of the symbols, and without Object.getOwnPropertySymbols leaking every symbol, we can use symbols as private field.
V8 already has implemented private Symbol (just one more boolean field when defining the struct symbol) though it is not exposed to Script-side.

> From: d at
> To: waldron.rick at; nbdd0121 at; es-discuss at
> Subject: RE: Proposal About Private Symbol
> Date: Sat, 20 Dec 2014 20:11:04 +0000
> For more reasons on why a simple "private symbol" approach does not quite work, see
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list