Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Why is "var name" variable initialized as a string when try to initialize it as an array in Javascript?

When I use "name" as a variable name and use var keyword, the "name" variable isn't initialized as array.

var name = ['banana', 'kiwi'];
Object.getPrototypeOf(name) == String.prototype; // true

But when I use const keyword it works normally.

const name = ['banana', 'kiwi'];
Object.getPrototypeOf(name) == Array.prototype; // true

Or when I use a different variable name, it works normally, too.

var name2 = ['banana', 'kiwi'];
Object.getPrototypeOf(name2) == Array.prototype; // true

Why does this happen?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!