I'm a hobby programmer, I've studied several languages and almost always find that 'length' is a method/function. I've been trained, from what I can tell, that any method call must be called with a parenthesis after, even with no arguments.
Not so in Javascript.... Why?
C# .length() ROR .lenth()
etc...
In Javascript it's a property, not a function.
In languages like C where the length function has to loop through the entire string to find the end, it's logical to have it as a function (as it does some work). In languages where the length is kept as a separate value, it's logical to have it as a property instead (as it only reads an already existing value).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With