ๅจ PHP ไธญ,ๅฏไปฅ็ฐกๅฎไฝฟ็จๆฏ่ผ้็ฎๅญๆฏๅฐๅ ฉๅ้ฃๅ。
$a = ['a', 'b', 'c'];
$b = ['a', 'b', 'c'];
var_dump($a === $b); // true
็่ณๆๅบไธไธๆจฃ้้ sort ไนๅฏไปฅ่งฃๆฑบ。
$a = ['a', 'b', 'c'];
$b = ['a', 'c', 'b'];
var_dump(sort($a) === sort($b)); // true
ไฝๅจ js ็ไธ็ไธ่ก。
const a = [
'a',
'b',
'c'
];
const b = [
'a',
'b',
'c'
];
console.log(a == b); // false
console.log(a === b); // false
ๅจ็ถฒ่ทฏไธ็ๅฐไธๅ่งฃๆณๆบๅฅฝ็,่จ้ไธไธ。
const a = [
'a',
'b',
'c'
];
const b = [
'a',
'b',
'c'
];
const result = a.sort().every((value, index) => {
return value === b.sort()[index];
});
console.log(result); // true
ๅฏซๆ prototype ๅฐฑๆฏ。
const a = [
'a',
'b',
'c'
];
const b = [
'a',
'b',
'c'
];
Array.prototype.equals = function (array) {
return this.sort().every((value, index) => {
return value === array.sort()[index];
});
}
console.log(a.equals(b)); // true