Skip to content
Advertisement

Nodejs module extends with other module

Hi i have parent module like this.

JavaScript

and a Child prototype class like this.

JavaScript

How i implement inheritance? I searched by google but no solution works for me.

Advertisement

Answer

As @jfriend00 said, I write these functions with class keyword which is a syntactic sugar for your code!

usermgmt.js

JavaScript

Write authentication like this.

authentication.js

JavaScript

And usage for authentication will be:

JavaScript

1) Use class and extends syntax which is easier.

2) Return Class and not its instance

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement