4 ms·
Given an object with a length property with the type a method expects, is there ever a scenario where the method is incorrect? I'm trying to wrap my head aroun
by jwdunne 9y ago
Given an object with a length property with the type a method expects, is there ever a scenario where the method is incorrect?
I'm trying to wrap my head around it: if a method needs only the length property, which is an unsigned int, is there any good reason why it shouldn't accept any object that has that property?
It appears at first that this is a good quality: the code is general whilst obviously avoiding any type errors, including null/undefined errors.
- slackingoff2017 9y agoThe type system is still working properly in that it will produce code that compiles and runs. For the developer such a behaviour can be misleading. This is compounded by IDE's with intellisense which will suggest passing random objects with the correct properties into the function.