In what scenarios will classes be used in node development?

module.exports can export objects directly and reference them directly.

unlike Java, only class can be introduced.

then why do Node developers need to use class?

Mar.17,2021

tell me about my own situation:
in actual production, it is almost not used. At present, it is mainly koa development

.

are all in the form of export function


because javascript is a language based on object prototypes, in fact, class is just a simulation of class effects, essentially an object.


are mainly some class libraries, with a high degree of reuse, and classes are the most appropriate. If you are on typescript or es6, you are basically writing classes


, to be honest, there are quite a lot, but js itself does not have a class, so you can understand it as a class, or to export a function.
such as sequelize and mongoose have many class concepts, for example, they usually inherit Error to implement their own Error class, but you say that is function , which is also true, or even more accurate. What can I say. Mainly by concept.


in fact, class is just grammatical sugar, which is written differently like the principle of es5, but is more inclined to the strong language type of java. There is not much difference between class and ordinary functions, so it encapsulates commonly used code. But personally, it is neat and readable to use class, which is convenient for other developers to use and understand

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b42b1b-2c62d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b42b1b-2c62d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?