I want to check whether moment object is valid or not, so i used both isValid() and _isValid in different places. Both are giving same results. So i want to know purpose of using both.
Note: I know basic diff that one is function and other one is attribute.
I want to check whether moment object is valid or not, so i used both isValid() and _isValid in different places. Both are giving same results. So i want to know purpose of using both.
Note: I know basic diff that one is function and other one is attribute.
Share Improve this question asked Mar 29, 2017 at 6:45 Mallikarjuna RaoMallikarjuna Rao 2111 gold badge4 silver badges18 bronze badges1 Answer
Reset to default 6isValid()
is documented and so using it in prodution code is fine. It tells you whether the Moment instance contains a valid date/time.
_isValid
is not documented and so using it in production code is a bad idea. It doesn't officially tell you anything. Its meaning could change, or it could disappear entirely, from one Moment to the next (see what I did there? ;-) ).
In general, in JavaScript, when you see a property name prefixed with _
it means "this is internal, pretend you don't see it."