动作脚本3:检查数组是否匹配

red*_*ory 4 arrays match actionscript-3

如果您有一个包含六个数字的数组,请说:

public var check:Array = new Array[10,12,5,11,9,4];
Run Code Online (Sandbox Code Playgroud)

要么

public var check:Array = new Array[10,10,5,11,9,4];
Run Code Online (Sandbox Code Playgroud)

你如何检查一对(一对?)

Ama*_*osh 6

Arrayclass有一个indexOf方法:

function indexOf(searchElement:*, fromIndex:int = 0):int

使用严格相等(===)搜索数组中的项,并返回项的索引位置.

参数

  • searchElement:* - 要在数组中查找的项目.
  • fromIndex:int (默认值= 0) - 数组中从中开始搜索项目的位置.

返回

  • int - 数组中项的从零开始的索引位置.如果searchElement未找到参数,则返回值为-1.