Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1067066 of TypeError: More arguments needed

  • Revision slug: Web/JavaScript/Reference/Errors/More_arguments_needed
  • Revision title: TypeError: More arguments needed
  • Revision id: 1067066
  • Created:
  • Creator: fscholz
  • Is current revision? Yes
  • Comment new page

Revision Content

{{jsSidebar("Errors")}}

Message

TypeError: Object.create requires more than 0 arguments
TypeError: Object.setPrototypeOf requires more than 1 argument
TypeError: Object.defineProperties requires more than 0 arguments

Error type

{{jsxref("TypeError")}}.

What went wrong?

There is an error with how a function is called. More arguments need to be provided.

Examples

The {{jsxref("Object.create()")}} method requires at least one argument and the {{jsxref("Object.setPrototypeOf()")}} method requires at least two arguments:

var obj = Object.create();
// TypeError: Object.create requires more than 0 arguments

var obj = Object.setPrototypeOf({});
// TypeError: Object.setPrototypeOf requires more than 1 argument

You can fix this by setting {{jsxref("null")}} as the prototype, for example:

var obj = Object.create(null);

var obj = Object.setPrototypeOf({}, null);

See also

Revision Source

<div>{{jsSidebar("Errors")}}</div>

<h2 id="Message">Message</h2>

<pre class="syntaxbox">
TypeError: Object.create requires more than 0 arguments
TypeError: Object.setPrototypeOf requires more than 1 argument
TypeError: Object.defineProperties requires more than 0 arguments
</pre>

<h2 id="Error_type">Error type</h2>

<p>{{jsxref("TypeError")}}.</p>

<h2 id="What_went_wrong">What went wrong?</h2>

<p>There is an error with how a function is called. More arguments need to be provided.</p>

<h2 id="Examples">Examples</h2>

<p>The&nbsp;{{jsxref("Object.create()")}} method requires at least one argument and the {{jsxref("Object.setPrototypeOf()")}} method requires at least two arguments:</p>

<pre class="brush: js example-bad">
var obj = Object.create();
// TypeError: Object.create requires more than 0 arguments

var obj = Object.setPrototypeOf({});
// TypeError: Object.setPrototypeOf requires more than 1 argument
</pre>

<p>You can fix this by setting {{jsxref("null")}} as the prototype, for example:</p>

<pre class="brush: js example-good">
var obj = Object.create(null);

var obj = Object.setPrototypeOf({}, null);</pre>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/JavaScript/Guide/Functions">Functions</a></li>
</ul>
Revert to this revision