From 522984283b56b68582d606c76e4ca98c0baf9451 Mon Sep 17 00:00:00 2001 From: MDN Date: Tue, 15 Jun 2021 00:35:40 +0000 Subject: [CRON] sync translated content --- .../typed_array_invalid_arguments/index.html | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 files/ja/orphaned/web/javascript/reference/errors/typed_array_invalid_arguments/index.html (limited to 'files/ja/orphaned/web/javascript/reference') diff --git a/files/ja/orphaned/web/javascript/reference/errors/typed_array_invalid_arguments/index.html b/files/ja/orphaned/web/javascript/reference/errors/typed_array_invalid_arguments/index.html new file mode 100644 index 0000000000..b02af7aa13 --- /dev/null +++ b/files/ja/orphaned/web/javascript/reference/errors/typed_array_invalid_arguments/index.html @@ -0,0 +1,78 @@ +--- +title: 'TypeError: invalid arguments' +slug: orphaned/Web/JavaScript/Reference/Errors/Typed_array_invalid_arguments +tags: + - Error + - Errors + - JavaScript + - TypeError +translation_of: Web/JavaScript/Reference/Errors/Typed_array_invalid_arguments +original_slug: Web/JavaScript/Reference/Errors/Typed_array_invalid_arguments +--- +
{{jsSidebar("Errors")}}
+ +

メッセージ

+ +
TypeError: invalid arguments (Firefox)
+ +

エラータイプ

+ +

{{jsxref("TypeError")}}

+ +

何がうまくいかなかったのか?

+ +

新しい typed array を生成するために、Typed array コンストラクターに以下のいずれかの値を渡す必要があります。

+ + + +

そのほかのコンストラクター引数では、有効な typed array を生成できません。

+ +

+ +

Typed array、たとえば {{jsxref("Uint8Array")}} は文字列から構成できません。事実、文字列はまったく typed array にすることはできません。

+ +
var ta = new Uint8Array("nope");
+// TypeError: invalid arguments
+
+ +

有効な {{jsxref("Uint8Array")}} を生成するほかの方法:

+ +
// From a length
+var uint8 = new Uint8Array(2);
+uint8[0] = 42;
+console.log(uint8[0]); // 42
+console.log(uint8.length); // 2
+console.log(uint8.BYTES_PER_ELEMENT); // 1
+
+// From an array
+var arr = new Uint8Array([21,31]);
+console.log(arr[1]); // 31
+
+// From another TypedArray
+var x = new Uint8Array([21, 31]);
+var y = new Uint8Array(x);
+console.log(y[0]); // 21
+
+// From an ArrayBuffer
+var buffer = new ArrayBuffer(8);
+var z = new Uint8Array(buffer, 1, 4);
+
+// From an iterable
+var iterable = function*(){ yield* [1,2,3]; }();
+var uint8 = new Uint8Array(iterable);
+// Uint8Array[1, 2, 3]
+
+ +

関連項目

+ + -- cgit v1.2.3-54-g00ecf