AS3检查两个不同数组中的所有值是否相同

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AS3检查两个不同数组中的所有值是否相同相关的知识,希望对你有一定的参考价值。

I'm not sure whether I should be using == (Equality) or === (Strict equality) here. I haven't been able to create a situation where it makes much difference. If you know better, feel free to leave me a comment.
  1. var array1:Array = new Array(1,2,3,4,5,6,7);
  2. var array2:Array = new Array(1,2,3,9,5,6,7);
  3.  
  4. function checkIfArraysMatch($arrayA:Array, $arrayB:Array):Boolean
  5. {
  6. var isMatch:Boolean = true;
  7. if($arrayA.length == $arrayB.length) {
  8. for (var i:int = 0; i<$arrayA.length; i++) {
  9. if ($arrayA[i] != $arrayB[i]) {
  10. isMatch = false;
  11. break;
  12. }
  13. }
  14. } else {
  15. isMatch = false;
  16. }
  17. return isMatch;
  18. }
  19.  
  20.  
  21. trace(checkIfArraysMatch(array1, array2));
  22.  
  23. // OUTPUT: false

以上是关于AS3检查两个不同数组中的所有值是否相同的主要内容,如果未能解决你的问题,请参考以下文章