Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/array.js>equals

A JavaScript extension package for building strong and modern applications.
Latest
function equals
import { equals } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/array.js";

Performs a shallow compare to another array and see if it contains the same elements as this array.

NOTE: This function only performs a shallow comparison, to compare nested objects in the array, use the equals function from @ayonli/jsext/object module instead.

Examples

Example 1

import { equals } from "@ayonli/jsext/array";

const arr1 = [1, 2, 3, 4, 5];
const arr2 = [{ foo: "bar" }];

console.log(equals(arr1, [1, 2, 3, 4, 5])); // true
console.log(equals(arr2, [{ foo: "bar" }])); // false, object refs are different

Parameters

arr1
arr2