@black_hole/array-equals
v1.1.3
Published
check if two arrays are equal
Downloads
6
Maintainers
Readme
Array-equals
install
# Install with npm
$ npm install @black_hole/array-equals --save
# Install with yarn
$ yarn add @black_hole/array-equals
Usage
Two arrays are equal
let arrEquals = require('@black_hole/array-equals')
let arr1 = [1, 2, 3]
let arr2 = [1, 2, 3]
let result = arrEquals(arr1, arr2) // => true
Two arrays are not equal
let arrEquals = require('@black_hole/array-equals')
let arr1 = [1, 2, 3]
let arr2 = [1, 2, 4]
let result = arrEquals(arr1, arr2) // => false
Arrays of different lengths are not equal
let arrEquals = require('@black_hole/array-equals')
let arr1 = [1, 2, 3]
let arr2 = [1, 2, 3, 4]
let result = arrEquals(arr1, arr2) // => false
Multidimensional array are equal
let arrEquals = require('@black_hole/array-equals')
let arr1 = [1, 2, 3, [4, 5, 6]]
let arr2 = [1, 2, 3, [4, 5, 6]]
let result = arrEquals(arr1, arr2) // => true
Arguments(like-Array) are equal
let arrEquals = require('@black_hole/array-equals')
function likeArr () {
let arr2 = [1, 2, 3]
return arrEquals(arguments, arr2, true)
}
likeArr(1, 2, 3) // => true
Depth judgment
let arrEquals = require('@black_hole/array-equals')
let arr1 = [1, {
'a': 1,
'b': ['x', null, -0]
}]
let arr2 = [1, {
'a': 1,
'b': ['x', null, 0]
}]
let result = arrEquals(arr1, arr2) // => false
Contributing
| Commits | Contributor | | --- | --- | | 5 | Black-Hole |
Author
Black-Hole
- Email:[email protected]
- Blog:http://bugs.cc
- WeiBo:http://weibo.com/comelove
- Twitter:https://twitter.com/Free_BlackHole