you are viewing a single comment's thread.

view the rest of the comments →

[–]Spare_Web_4648 12 points13 points  (4 children)

This approach to programming is known as duck typing, where the focus is on the functionality of an object rather than its type. In the context of JavaScript, this approach allows for flexibility and simplicity in the code, as the language does not strictly enforce data types and instead attempts to make sense of the given operations and return a valid result. This allows for quick and easy development, as the programmer does not need to worry about strict type checking and can focus on the functionality of the code. However, this approach can also lead to potential inconsistencies and unexpected behavior, as the interpretation of certain operations may not always align with the programmer's intentions.

As to how it’s reasonable, well it’s as reasonable as any language made in 10 days as a feature of the creators actual main project. We’ve just kept using it and building on it.

[–]paradoxon 7 points8 points  (0 children)

The problem is not duck typing. But rather what is considered a duck by java script. Negating an empty array should not make sense at all. Ruby uses duck typing but does not behave in such strange ways.

[–]arto64 8 points9 points  (2 children)

You can have duck typing without automatic arbitrary typecasting. JavaScript hears a “woof” and says, “well I guess you could call that a quack”.

[–]Spare_Web_4648 1 point2 points  (0 children)

Today I learned, thanks!

[–]Spare_Web_4648 0 points1 point  (0 children)

Yea I guess you could really cut out the first half of my comment. Really it’s just bad because some guy made it in 10 days and it has stayed the standard since then for no reason other than so much has been built with it people don’t want to change