在 Javascript 中,“for (attr in this)”通常使用起来很危险……我同意。这也是我喜欢 Coffeescript 的原因之一。但是,我正在使用 Coffeescript 编程,并且有一个需要 Javascript 的“for (attr in this)”的情况。在 Coffeescript 中有没有好的方法来做到这一点?
我现在正在做的是在嵌入式原始 Javascript 中编写一堆逻辑,例如:
...coffeescript here...
for (attr in this) {
if (stuff here) {
etc
}
}
尽可能少地使用 Javascript 会很好......关于如何实现这一点并最大限度地利用 Coffeescript 的任何建议?