干掉一些代码

时间:2011-10-29 14:43:10

标签: javascript jquery

我正在烘干以从jQuery源代码中干掉这段代码:

cssNumber: {
    "fillOpacity": true,
    "fontWeight": true,
    "lineHeight": true,
    "opacity": true,
    "orphans": true,
    "widows": true,
    "zIndex": true,
    "zoom": true
}

我建议如下。可以做得更好吗?

cssNumber: {}
"fillOpacity fontWeight lineHeight opacity orphans windows zIndex zoom"
    .split(" ")
    .forEach(function() {
        cssNumber.name = true;
    });

1 个答案:

答案 0 :(得分:0)

如果你真的需要节省字节空间,我只会这样做。你想要做的是用值填充对象。比你应该的那样。这是你的第一个代码。