blob: b0a1f924c423af77e82e3ed7ec8c55613b0c3e76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
---
title: 'TypeError: More arguments needed'
slug: Web/JavaScript/Reference/Errors/More_arguments_needed
tags:
- Error
- Errors
- JavaScript
- TypeError
translation_of: Web/JavaScript/Reference/Errors/More_arguments_needed
---
<div>{{jsSidebar("Errors")}}</div>
<p>JavaScript の例外 "more arguments needed" は、関数の呼び出し方にエラーがあった場合に発生します。もっと多くの引数が必要です。</p>
<h2 id="Message">エラーメッセージ</h2>
<pre class="brush: js">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
</pre>
<h2 id="エラータイプ">エラータイプ</h2>
<p>{{jsxref("TypeError")}}</p>
<h2 id="何がうまくいかなかったのか?">何がうまくいかなかったのか?</h2>
<p>関数の呼び出し方にエラーがあります。より多くの引数を提供する必要があります。</p>
<h2 id="例">例</h2>
<h3 id="Required_arguments_not_provided">必要な引数が足りない</h3>
<p>{{jsxref("Object.create()")}} メソッドは、少なくとも 1 つは引数が必要です。また、{{jsxref("Object.setPrototypeOf()")}} メソッドは少なくとも 2 つ引数が必要です。</p>
<pre class="brush: js example-bad">var obj = Object.create();
// TypeError: Object.create requires at least 1 argument, but only 0 were passed
var obj = Object.setPrototypeOf({});
// TypeError: Object.setPrototypeOf requires at least 2 arguments, but only 1 were passed
</pre>
<p>たとえば、{{jsxref("null")}} を prototype として設定することで修正できます。</p>
<pre class="brush: js example-good">var obj = Object.create(null);
var obj = Object.setPrototypeOf({}, null);</pre>
<h2 id="関連項目">関連項目</h2>
<ul>
<li><a href="/ja/docs/Web/JavaScript/Guide/Functions">関数</a></li>
</ul>
|