What a method prefixed with `#` means?
This is perhaps the stupidest question ever. But I often see method with names prefixed with a
#
character in typescript. What does it mean? Google does not seems to know either.
example: https://deno.land/std@0.187.0/streams/text_line_stream.ts?source#L404 Replies
It's a private method
Private class features - JavaScript | MDN
Class fields are public by default, but private class members can be created by using a hash # prefix. The privacy encapsulation of these class features is enforced by JavaScript itself.
nice, thanks a lot. I was using the
private
keyword.private
is TypeScript-level private only, ie. in runtime the property or method is still entirely public and visible there. #
is runtime-private as well, and it is actually one of the strongest possible flavours of privateness, eg. private class fields cannot be accessed by sub-classes.
In short: There's a time and place for both.