Sometimes, we may run into the ‘TypeError: More arguments needed’ when we’re developing JavaScript apps.
In this article, we’ll look at how to fix the ‘TypeError: More arguments needed’ when we’re developing JavaScript apps.
Fix the ‘TypeError: More arguments needed’ When Developing JavaScript Apps
To fix the ‘TypeError: More arguments needed’ when we’re developing JavaScript apps, we should make sure that we’re passing in all the required arguments to the Object.create
and Object.setPrototypeOf
methods.
Different variations of this error includes:
TypeError: argument is not an Object and is not null (Edge)
TypeError: Object.create requires at least 1 argument, but only 0 were passed
TypeError: Object.setPrototypeOf requires at least 2 arguments, but only 0 were passed
TypeError: Object.defineProperties requires at least 1 argument, but only 0 were passed
For instance, if we have:
const obj = Object.create();
const obj = Object.setPrototypeOf({});
In the first line, we didn’t pass in any arguments into Object.create
which are expected.
And in the 2nd line, we’re missing the 2nd argument.
To fix this, we write:
const obj = Object.create(null);
const obj = Object.setPrototypeOf({}, null);
Conclusion
To fix the ‘TypeError: More arguments needed’ when we’re developing JavaScript apps, we should make sure that we’re passing in all the required arguments to the Object.create
and Object.setPrototypeOf
methods.