deepEqual

deepEqual(x, y)

Try it yourself:


deepEqual(): Comparing Complete Values

deepEqual() tests whether two values have the same content throughout their structure. Unlike a simple identity test, it is intended for arrays, matrices, objects, and nested collections where every corresponding member matters. For example, deepEqual([1, 2], [1, 2]) is true, while deepEqual([1, 2], [2, 1]) is false because order differs.

What “deep” means

A deep comparison descends into nested values rather than comparing only the outer container. That makes it useful for checking expected results in calculations, validating imported data, and confirming that a transformation preserved information. Use equal() for ordinary equality and compare() when an ordering result is more useful than a boolean.

Be deliberate about numeric precision. Values that print similarly can still differ by a tiny floating-point amount, so exact deep equality is not usually the right test for measured or iterative results. Compare an error against a tolerance with abs() instead. For matrices, inspect dimensions with size() before diagnosing a failed comparison.

Practical checks

deepEqual is especially helpful after clone(), parsing, or reshaping data: it can verify that values match while remaining separate values in a workflow. It does not mean two values are mathematically “close”; it means their represented structure and contents agree exactly.

Try Deep Equal in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions