JavaScript的:可以用逗号将数组中的最后一组值后发生的? [英] javaScript: Can a comma occur after the last set of values in an array?

查看:197
本文介绍了JavaScript的:可以用逗号将数组中的最后一组值后发生的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如果一个逗号尾随在JavaScript的数组是有效的?

I am wondering if a comma trailing an array in javascript is valid?

var settings = {
    'foo'  : oof,
    'bar' : rab,
};

VS

var settings = {
    'foo'  : oof,
    'bar' : rab
};

请注意第二个例子不具有的最后一个键/值后加上逗号。

Note the second example does not have a comma after the last key/value.

推荐答案

大多数浏览器和实现做让后面的逗号,大的
Internet Explorer的。

Most browsers and implementations do allow a trailing comma, the big BUT is the "Internet Explorer".

在大多数版本的InternetExplorer尾随逗号引起的 BIG 的麻烦。它会扔的奇怪疯狂的,奇怪的,不合理的错误 ..你不知道你在哪里!这是的可怕的,你就会陷入的的和严肃的德pressions 的。本病也有一个名字,末日恶逗号,它被称为一次。

A trailing comma in most InternetExplorer versions causes BIG trouble. It'll throw wierd, crazy, strange and unreasonable errors .. you have no idea where you're at! This is terrible, you'll fall into deep and serious depressions. The disease also has a name, "evil comma of doom" it was called once.

结论:从来没有。永远!在JavaScript中使用尾随逗号。

这篇关于JavaScript的:可以用逗号将数组中的最后一组值后发生的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆