JavaScript · Middle · Question 10 of 75
How does #count differ from _count in a class?
- ✓Correct answer:
#countis a truly private field: there's no access to it from outside - 2
_countis private by the standard, while#countis just a convention - 3No difference: both are equally accessible from outside the class
Explanation
An underscore is a convention; the property is still accessible. Private # fields are enforced by the engine: accessing obj.#count from outside is a syntax error. You can check for presence with #count in obj.