DEV Community


Discussion on: You don't need classes

lukeshiru profile image
▲ LUKE知る Author

The example using prototype is just there to illustrate that the classes are still just functions in JavaScript. My argument in the post is against classes in JS, mainly because if internally you're still using functions, you can just use them directly enabling better reuse, composition, testing and so on.
You can use modules to encapsulate, if you really want to have an object with methods you can create one putting several functions together, but you can't go the other way around (reuse or compose classes). You'll end up with the classic inheritance problem of wanting a banana and getting a gorilla holding that banana and the entire jungle.

Some comments have been hidden by the post's author - find out more