loading...

re: Improve Your Algorithms with this Simple Equation VIEW POST

TOP OF THREAD FULL DISCUSSION
re: maybe joel is talking about javascript. Hes right its a property of an array. Thats how V8 implements it (sorry I cant find the link but Its in v8....

When an item is added to or removed from the array, the length property is updated. You can check this by running this code:

const array = [1, 2, 3];
array.length = 100;

console.log(array.length) //=> 100

length NEEDS to be a property, otherwise code like this would become exponential:

for (let i = 0; i < input.length; i++) { }
code of conduct - report abuse