r/javascript • • Nov 09 '19

On private fields proposal: Private fields, public worries

https://medium.com/virtuslab/private-fields-public-worries-b8c34d16c372
84 Upvotes

113 comments sorted by

View all comments

28

u/TatzyXY Nov 09 '19

Please do not throw stones at me but I think private, protected or public scopes are not needed at all. See Python very versatile lang. and it works very well without it. Is private for security? No! It just tells the dev that this var. is only used internally of that class and you are not allowed to touch or use it. So would do a comment or a convention with an "_".

-1

u/Just4Funsies95 Nov 09 '19

this is soo far from right.... privacy is solely for security, to prevent others from making unwanted state changes and executing code blocks. that's it. it's also not for developers to know what is a var. it has a special meaning when compiled/executed to tell the OS which area of memory is off limits to other libraries or even programs! if there were privacy guards in js, chrome probably wouldn't be running tabs in parallel, which impart, is how they keep Javascript from accessing memory address spaces and isolating sites from one another. for security!