8 ms·
How does this work with JSON.stringify? Could I convert an object to a string and then scan the string to get the value of the private fields? (I am not great a
by shiado 8y ago
How does this work with JSON.stringify? Could I convert an object to a string and then scan the string to get the value of the private fields? (I am not great at the details of JS correct me here)
- Roboprog 8y agoThat’s actually a pretty good question. It’s probably in the spec, which is probably long :-)
- lioeters 8y agoLooks like JSON.stringify will not reveal a private field, based on this line from the spec: "What do you mean by "encapsulation" / "hard private"? It means that private fields are purely internal: no JS code outside of a class can detect or affect the existence, name, or value of any private field of instances of said class.." https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md#what-do-you-mean-by-encapsulation--hard-private https://github.com/tc39/proposal-class-fields/blob/master/PR...