Welcome to the Linux Foundation Forum!

Code error needs to be fixed

Tutorial: 05. KEY JAVASCRIPT CONCEPTS - Key JavaScript Concepts - Prototypal Inheritance (Constructor Functions)

Code util.inherits(Dog.prototype, Wolf.prototype) will throw error:

util.js:160
throw new ERR_INVALID_ARG_TYPE('superCtor.prototype',
^

TypeError [ERR_INVALID_ARG_TYPE]: The "superCtor.prototype" property must be of type object. Received undefined

According to node.js documentation, arguments of util.inherits should both be constructor instead of prototype. So if we pass prototypes into this function like the tutorial shows, error will occur.

The correct code should be
util.inherits(Dog, Wolf)

Comments

Categories

Upcoming Training