【发布时间】:2014-11-07 03:53:33
【问题描述】:
如果我有 3 个数组:
parent = [
'first',
'second',
'third',
'fourth',
]
parentX = [
'firstX',
'secondX',
'thirdX',
'fourthX',
]
parentY = [
'firstY',
'secondY',
'thirdY',
'fourthY',
]
我将如何在 coffeescript 中构建我的 for 循环,以便生成循环:
someThing.first.x = first.firstX
something.first.y = first.firstY
感谢您的想法!
【问题讨论】:
-
someThing到底应该是什么样子?你真的有一个名为first的变量还是你的意思是someThing.first应该是{ x: parentX[0], y: parentY[0] }? -
someThing只是一个包含一组图层的变量,所以我试图访问组中的第一层(这些图层被命名为'first''second''third'等)并设置它的 x 坐标,然后设置它的 y 坐标。我需要根据我正在工作的框架以这种方式进行操作。非常感谢您的任何想法!非常感谢您迄今为止的帮助,如果最初不清楚,请道歉。
标签: javascript arrays for-loop coffeescript