Noz*_*Noz 0 javascript jquery coffeescript
我正在尝试在JQuery中循环变量并重新分配this以下Coffeescript中的值.
$.each data.rows, ->
completion_time = [this[0], new Date(new Date('Jan 01 2000').getTime() + this[1])]
this = completion_time
Run Code Online (Sandbox Code Playgroud)
但是,这会产生以下错误消息:
SyntaxError:无法分配保留字"this"
在每次迭代中,值this看起来像这样:
["abc123",12302103,1230132,1230123]
我要做的是将其重新分配给以下值:
["abc123",12302103]
我也尝试过分配this.value,没有骰子.有什么建议?
You can't reassign this. You can modify this to contain the elements in the new array
I can't stand CoffeScript, so I'll just show it in JS
// Clear elements from the array
this.length = 0;
// Add each element in the new array
this.push.apply(this, completion_time);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
444 次 |
| 最近记录: |