我想在javascript中使用此代码:
beforeNode = children[ children.length -1 ]
使用coffeecript中的这段代码:
beforeNode = children[ children.length -1 ]
coffescript生成:
beforeNode = children[children.length(-1)];
如何在coffescript中编写源代码以生成预期的javascript代码?
由于
答案 0 :(得分:2)
不要使用空格!
// coffeescript
beforeNode = children[children.length-1]
或者在-
// coffeescript
beforeNode = children[children.length - 1]
结果
// js
var beforeNode;
beforeNode = children[children.length - 1];
答案 1 :(得分:0)
或者使用两个空格!
# coffeescript
beforeNode = children[children.length - 1]
结果
// javascript
var beforeNode;
beforeNode = children[children.length - 1];