What’s the difference between “Array()” and “[]” while declaring a JavaScript array?

来源:互联网 发布:sql语句设置别名 编辑:程序博客网 时间:2024/05/21 22:35
var a = [],            // these are the same    b = new Array(),  // a and b are arrays with length 0    c = ['foo', 'bar'],          // these are the same    d = new Array('foo', 'bar'),  // c and d are arrays with 2 strings    // these are different:    e = [3]            // e.length == 1, e[0] == 3    f = new Array(3),  // f.length == 3, f[0] == undefined;
0 0
原创粉丝点击