Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why global variable 'name' changes to string? [duplicate]

Tags:

javascript

When I make array object named "name", type automatically changes to "String", not "Array". Why?

<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>

Result in Chrome(Mac):

---------------------------------
["abc", "def"]
object
---------------------------------
ghi,jkl
string   // <- Why?
like image 830
wgkoro Avatar asked Feb 26 '26 10:02

wgkoro


1 Answers

https://developer.mozilla.org/en-US/docs/Web/API/Window.name

It is a string, because window.name has a purpose. You are setting the name of the window.

like image 171
epascarello Avatar answered Mar 01 '26 01:03

epascarello



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!