Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. JavaScript
  3. JavaScript リファレンス
  4. 標準組み込みオブジェクト
  5. TypedArray
  6. TypedArray.prototype.includes()

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

TypedArray.prototype.includes()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2016年9月⁩.

includes()TypedArray インスタンスのメソッドで、型付き配列の項目内に特定の値が含まれているかどうかを判断し、その結果に応じてtruefalse を返します。このメソッドはArray.prototype.includes() と同じアルゴリズムです。

試してみましょう

const uint8 = new Uint8Array([10, 20, 30, 40, 50]);console.log(uint8.includes(20));// Expected output: true// Check from position 3console.log(uint8.includes(20, 3));// Expected output: false

構文

js
includes(searchElement)includes(searchElement, fromIndex)

引数

searchElement

探す対象の要素

fromIndex省略可

検索を始める位置を示すゼロ基点のインデックスで、整数に変換されます

返値

論理値で、型付き配列(指定する場合はインデックスfromIndex で示される型付き配列の一部)内で値searchElement が見つかった場合にtrue なります。

解説

詳細については、Array.prototype.includes() をご覧ください。このメソッドは汎用的ではなく、型付き配列インスタンスに対してのみ呼び出すことができます。

includes の使用

js
const uint8 = new Uint8Array([1, 2, 3]);uint8.includes(2); // trueuint8.includes(4); // falseuint8.includes(3, 3); // false// NaN の扱い (Float32 および Float64 に限り true)new Uint8Array([NaN]).includes(NaN); // false (コンストラクターに渡した NaN は 0 に変換されるため)new Float32Array([NaN]).includes(NaN); // true;new Float64Array([NaN]).includes(NaN); // true;

仕様書

Specification
ECMAScript® 2026 Language Specification
# sec-%typedarray%.prototype.includes

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp