[英]How to write this simple javascript code in CoffeeScript?
我想在javascript中使用此代碼:
beforeNode = children[ children.length -1 ]
使用coffeecript中的這段代碼:
beforeNode = children[ children.length -1 ]
coffescript生成:
beforeNode = children[children.length(-1)];
如何在coffescript中編寫源代碼以生成預期的javascript代碼?
謝謝
不要使用空間!
// coffeescript
beforeNode = children[children.length-1]
或者在-
每一側使用一個空間-
// coffeescript
beforeNode = children[children.length - 1]
結果是
// js
var beforeNode;
beforeNode = children[children.length - 1];
或者使用兩個空格!
# coffeescript
beforeNode = children[children.length - 1]
結果是
// javascript
var beforeNode;
beforeNode = children[children.length - 1];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.