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

158
Views
How does the array get updated on updating the property 'length' of the array in JavaScript?

My question is if I use an array like this,

var arr1 = [1, 2, 3, 4];
console.log(arr1.length); // 4 (Expected)

If I update the length property, the array gets updated too.

arr1.length = 0;
console.log(arr1); // []

I'd like to know how this is being done (the internals)?

Also, I'm not sure if getter and setter methods of the property length (that are ways to run a function if the property gets accessed or set) are used here. I think they're not.

If it's being used, length should not be visible directly when I expand the array in the browser console. But we get the length directly without running any functions.

The console when I use get/set for a property of an object,

using get/set

Getting the value of length property directly without running any functions,

length of array

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!