【发布时间】:2016-06-21 19:46:57
【问题描述】:
我需要通过它们的名称一一访问一些数组,但是因为它们将被一一调用,所以我无法通过直接调用它们的名称来访问它们。 我所拥有的是这样的:
var cat1 : []
var cat2 : []
var cat3 : []
var cat4 : []
var cat5 : []
for () {
"Here there is some code that is different based on which array I'm dealing with"
}
我不知道如何为此编写“for循环”。
【问题讨论】:
-
创建一个数组数组:
var allCats = [cat1, cat2, cat3, cat4, cat5]并在allCats上创建一个外循环。