谷歌闭包是否有一个包含函数,我可以在其中指定比较函数?

发布于 2024-10-10 01:00:11 字数 417 浏览 0 评论 0原文

我有一个 DateObjects 和 DateRange-Objects 数组以及一个 DateObject。

我想知道这个单个日期是否在 DateObjects 数组中或在一个 DateRange-Object 的范围内。

goog.array.contains(arr, obj) 几乎是我想要的,但我想要 goog.date.isSameDay(date, opt_now) 函数进行比较。

Google 闭包是否有一个包含函数,我可以在其中指定比较函数?

I have an array of DateObjects and DateRange-Objects and a single DateObject.

I would like to know if this single Date is in the array of DateObjects or in the range of one DateRange-Object.

goog.array.contains(arr, obj) is almost what I want, but I would like the goog.date.isSameDay(date, opt_now) function to compare.

Has google closure a contains-function where I can specify the comparing function?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小傻瓜 2024-10-17 01:00:11

find/findIndex 可能就是您要查找的内容。像这样的东西:

goog.array.find(dates, goog.partial(goog.date.isSameDay, singleDateObject));
goog.array.findIndex(ranges, function(range) { /* your comparison */ });

find/findIndex might be what you're looking for. Something like:

goog.array.find(dates, goog.partial(goog.date.isSameDay, singleDateObject));
goog.array.findIndex(ranges, function(range) { /* your comparison */ });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文