数组和对象中的尾随逗号是规范的一部分吗?
2022-08-30 00:57:33
尾随逗号在JavaScript中是标准的,还是像Chrome和Firefox这样的大多数浏览器只是容忍它们?
我以为它们是标准的,但是IE8在遇到一个后就噗
以下是我的意思的一个例子(在books数组的最后一个元素之后):
var viewModel = {
books: ko.observableArray([
{ title: "..", display: function() { return ".."; } },
{ title: "..", display: function() { return ".."; } },
{ title: "..", display: function() { return ".."; } }, // <--right there
]),
currentTemplate: ko.observable("bookTemplate1"),
displayTemplate: function() { return viewModel.currentTemplate(); }
};