JavaScript/object:修订间差异
来自康健生活
| 第84行: | 第84行: | ||
return true; | return true; | ||
};</syntaxhighlight>|{{consoleout|<pre> | };</syntaxhighlight>|{{consoleout|<pre> | ||
</pre>}}}} | |||
=== deep Equal === | |||
{{leftrightflex|<syntaxhighlight lang="javascript"> | |||
const deepEqual = (x, y) => { | |||
const ok = Object.keys, tx = typeof x, ty = typeof y; | |||
return x && y && tx === 'object' && tx === ty | |||
? (ok(x).length === ok(y).length && ok(x).every(key => deepEqual(x[key], y[key]))) | |||
: (x === y); | |||
}</syntaxhighlight>|{{consoleout|<pre> | |||
</pre>}}}} | </pre>}}}} | ||
2023年3月28日 (二) 08:09的版本
No categories