相关疑难解决方法(0)

为什么全局变量'name'更改为字符串?

当我创建名为"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>
Run Code Online (Sandbox Code Playgroud)

Chrome(Mac)中的结果:

---------------------------------
["abc", "def"]
object
---------------------------------
ghi,jkl
string   // <- Why?
Run Code Online (Sandbox Code Playgroud)

javascript

3
推荐指数
1
解决办法
95
查看次数

标签 统计

javascript ×1