最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is difference between isValid() and _isValid in moment.js? - Stack Overflow

programmeradmin5浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 6

isValid() 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."

发布评论

评论列表(0)

  1. 暂无评论