gpt4 book ai didi

javascript - Cortex 无法提供包装数组的所有方法

转载 作者:行者123 更新时间:2023-11-30 17:23:21 26 4
gpt4 key购买 nike

我正在使用 Cortex管理一些用于 React 应用程序的数据。

Cortex's API listing列出了一些只存在于数组上的方法,即 filterfind

给定一个对象:

var student = {
schedules: [
{
id: 1, year: 2012, semester: 1,
title: "Schedule 1", sequence: 1,
clbids: [82908, 82768, 82792, 83505],
active: true,
},
{
id: 2, year: 2012, semester: 2,
title: "Schedule 1", sequence: 1,
clbids: [85898],
active: true,
}
]
}

我希望 Cortex 理解 student.schedules 是一个数组。

cortexStudent = new Cortex(student)
cortexStudent.schedules.__isArray() // returns `true`

因此,Cortex 应该会提供findfilter 方法吧?

cortexStudent.schedules.find(function(schedule) {
return schedule.active.val() === true
})
cortexStudent.schedules.filter(function(schedule) {
return schedule.active.val() === true
})

没有。 find 完美运行,但 filter 抛出 TypeError: 'undefined' is not a function

您是否同意这是一个错误?我只需要有人在我报告之前仔细检查我。

( JSBin w/sample code. )

最佳答案

据我所知,这是一个错误。 .filter() 方法是最近才添加的,但出于某种原因当时没有更新库的缩小版本。如果您包含未缩小的版本,该功能似乎可以使用。

最好记录一个错误,以便维护者可以修复它;我不会这样做,因为我对图书馆一无所知。

关于javascript - Cortex 无法提供包装数组的所有方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24727093/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com