2011-04-14 68 views

回答

4

打破你写什么......

out += (
    out ? 
     rogueArray[14] : 
     rogueArray[13] 
    ) + 
    arrayItem + 
    (
     (vanWilder[arrayItem] !== null) ? 
     //Oh no! What's this assignment doing here? 
     = + encodeURIComponent(vanWilder[arrayItem]) : rogueArray[13]); 

同时,它会更容易调试你的代码,如果你不喜欢的东西如下:

if (out) { 
    out += rogueArray[14] 
} else { 
    out += rogueArray[13] 
} 
out += arrayItem 

if (vanWilder[arrayItem] !== null) { 
    out += encodeURIComponent(vanWilder[arrayItem]) 
} else { 
    out += rogueArray[13] 
} 
+0

现在,错误的是在最后一行? – Amanda 2011-04-14 02:35:10

+0

+1 @ NT3RP让这些三元运算符离开那里。代码应该写成* read *。保存三元组以缩小,混淆和复数化。 – codelahoma 2011-04-14 02:38:18

1

你有一个赋值操作符漂浮在表达式中。删除它,它应该在语法上是正确的。

2

我不确定是什么? = +意味着,但是真的,如果你只写这个,那么在一行中就太多了。如果你真的需要在它的工作之后,一次一个地做这一步,那么将它拆分成单独的行,使用临时变量,然后将它重构为紧凑的带有嵌套的第三级操作符的班轮。