JavaScript 语法错误

发布于 2024-11-01 17:48:11 字数 376 浏览 4 评论 0原文

out += (out ? rogueArray[14] : rogueArray[13]) + arrayItem + ((vanWilder[arrayItem] !== null) ? = + encodeURIComponent(vanWilder[arrayItem]) : rogueArray[13]);

据推测,在 Dreamweaver 中的 [arrayItem 之前] 线上存在语法错误。有什么帮助吗?

这是 DreamWeaver 中的图像:

https://i.sstatic.net/ITqV3.jpg

out += (out ? rogueArray[14] : rogueArray[13]) + arrayItem + ((vanWilder[arrayItem] !== null) ? = + encodeURIComponent(vanWilder[arrayItem]) : rogueArray[13]);

There is supposedly a syntax error here on the line up until [arrayItem in Dreamweaver. Any help?

Here is image of it in DreamWeaver:

https://i.sstatic.net/ITqV3.jpg

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

留蓝 2024-11-08 17:48:11

分解你所写的内容...

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]
}

Breaking down what you've written...

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

As well, it would be easier to debug your code if you did something like the following:

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

if (vanWilder[arrayItem] !== null) {
    out += encodeURIComponent(vanWilder[arrayItem])
} else {
    out += rogueArray[13]
}
摇划花蜜的午后 2024-11-08 17:48:11

我不确定什么? = + 的意思是,但实际上,如果您只是写这个,那么一行中发生的事情太多了。将其分成单独的行,使用临时变量,然后将其重构为带有嵌套三级运算符的紧凑单行(如果您确实需要在其工作后这样做),一次执行此一步。

I'm not sure what ? = + means, but really, that's too much going on in one line if you're just writing this. Break it apart into separate lines, use temporary variables, and then refactor it down to a compact one liner with nested tertiary operators if you really need to after it works, doing this one step at a time.

哥,最终变帅啦 2024-11-08 17:48:11

您有一个赋值运算符浮动在该表达式的中间。删除它,它在语法上应该是正确的。

You have an assignment operator floating around in the middle of that expression. Remove it and it should be syntactically correct.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文