求大神給我解釋下count++在這里的含義
</head>
<body>
??? <script type="text/javascript">? ?
??????? /*
???????? * param1 Array
???????? * param2 Array
???????? * return true or false
???????? */
??????? function arraysSimilar(arr1, arr2){
??????? var count = 0;
??????? if ((Object.prototype.toString.call(arr1) === '[object Array]') && (Object.prototype.toString.call(arr2) === '[object Array]')){
??????????? if (arr1.length === arr2.length){
??????????????? for(var i=0;i<arr1.length;i++){
??????????????????? for(var j=0;j<arr2.length;j++){
??????????????????????? if (Object.prototype.toString.call(arr1[i]) === Object.prototype.toString.call(arr2[j])){
??????????????????????????? count ++;
??????????????????????? }
??????????????????? }
??????????????? }
??????????????? if (count === arr1.length){
??????????????????? return true;
??????????????? }
??????????? }
??????? }
??????? return false;
??? }
??? </script>
??? <script src="testData.js"></script>
</body>
</html>
2017-07-13
相當(dāng)于一個計數(shù)器吧
把數(shù)組元素一個一個相互比較
成功一個count ++
當(dāng)count 等于數(shù)組長度時
就代表兩個數(shù)組里的元素全部進(jìn)行完比較并且相同了