HOME > > > >

indexOf

__.indexOf(array, value, [isSorted])

array
array
value
mixed
isSorted
int

arrayに、valueがあった場合、indexを返す

サンプル

実行結果

実行 削除

Javascript

  1. const debug1 = new Debug('#code1-dump');
  2. $('span#code1-execute').on('click', (e) => {
  3.     const arg = [
  4.         '赤・緑・青',
  5.         'ピカチュウ',
  6.         '金・銀',
  7.         'クリスタルバージョン',
  8.         'ルビー・サファイア',
  9.         'ファイアレッド・リーフグリーン/エメラルド',
  10.         'ダイヤモンド・パール',
  11.         'プラチナ',
  12.         'ハートゴールド・ソウルシルバー',
  13.         'ブラック・ホワイト',
  14.         'ブラック2・ホワイト2',
  15.         'X・Y',
  16.         'オメガルビー・アルファサファイア',
  17.         'サン・ムーン',
  18.         'ウルトラサン・ウルトラムーン',
  19.         'Let\'s Go! ピカチュウ・Let\'s Go! イーブイ',
  20.     ];
  21.     const value = _.indexOf(arg, 'プラチナ');
  22.     debug1.dump(value);
  23. });
  24.  
  25. $('span#code1-console-clear').on('click', (e) => {
  26.     debug1.clear();
  27. });

HTML

  1. <span class="cq-btn m-success" id="code1-execute">実行</span>
  2. <span class="cq-btn m-danger" id="code1-console-clear">削除</span>
  3. <div id="code1-dump"></div>
参照サイト