当我创建名为“name”的数组对象时,类型会自动更改为“String”,而不是“Array”。为什么?
<body>
<script>
console.log('---------------------------------');
var name1 = ['abc', 'def'];
console.log(name1);
console.log(typeof name1);
console.log('---------------------------------');
var name = ['ghi', 'jkl'];
console.log(name);
console.log(typeof name);
</script>
</body>
结果在 Chrome(Mac):
---------------------------------
["abc", "def"]
object
---------------------------------
ghi,jkl
string // <- Why?