Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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)


Looks 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/PR...


That’s actually a pretty good question. It’s probably in the spec, which is probably long :-)




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: