A simple way to implement protected

I was only accessing the property inside the class, and the property is supposed to be private. Believe me, I would have marked the variable as just foo to mark it as public if I was using it outside the class. :)

See here for a problem example:



Random fun, but I've implemented "friends" or similar features here: https://github.com/trusktr/lowclass/blob/dbb10b0c97a6690aabf4549c46a12baa8bd19ed5/src/Class.ts

Unit tests for that here: https://github.com/trusktr/lowclass/blob/dbb10b0c97a6690aabf4549c46a12baa8bd19ed5/src/tests/friends.test.js

1 Like