看三个例子:
代码语言:javascript复制a = [
age: 1
,
age: 2
]
a.forEach (item) ->
item.age = 0 # 有效
console.log a
# [
# age: 0
# ,
# age: 0
# ]
代码语言:javascript复制b = [1, 2]
b.forEach (item) ->
item = 0 # 无效
console.log b
# [1, 2]
代码语言:javascript复制b = [1, 2]
b.forEach (item, index, arr) ->
arr[index] = 0 # 有效
console.log b
# [1, 2]