README.md (2270B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # deepEqual 22 23 > Test for deep equality between two values. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var deepEqual = require( '@stdlib/assert/deep-equal' ); 31 ``` 32 33 #### deepEqual( a, b ) 34 35 Returns a `boolean` indicating if `a` is deep equal to `b`. 36 37 <!-- eslint-disable object-curly-newline, object-curly-spacing --> 38 39 ```javascript 40 var bool = deepEqual( [ 1, 2, 3 ], [ 1, 2, 3 ] ); 41 // returns true 42 43 bool = deepEqual( [ 1, 2, 3 ], [ 1, 2, '3' ] ); 44 // returns false 45 46 bool = deepEqual( { 'a': 2 }, { 'a': [ 2 ] } ); 47 // returns false 48 ``` 49 50 </section> 51 52 <!-- /.usage --> 53 54 <section class="notes"> 55 56 ## Notes 57 58 - The function uses strict equality checks (`===`) and does not perform any type coercion. 59 - When given two objects, only enumerable own properties are recursively compared. 60 61 </section> 62 63 <!-- /.notes --> 64 65 <section class="examples"> 66 67 ## Examples 68 69 <!-- eslint no-undef: "error", object-curly-newline: "off", object-curly-spacing: "off" --> 70 71 ```javascript 72 var deepEqual = require( '@stdlib/assert/deep-equal' ); 73 var bool; 74 var a; 75 var b; 76 77 a = [ true, false, true ]; 78 b = [ true, false, true ]; 79 bool = deepEqual( a, b ); 80 // returns true 81 82 b.pop(); 83 bool = deepEqual( a, b ); 84 // returns false 85 86 a = { 'a': { 'b': { 'c': 'd' } } }; 87 b = { 'a': { 'b': { 'c': 'd' } } }; 88 bool = deepEqual( a, b ); 89 // returns true 90 91 b.a.b.c = null; 92 bool = deepEqual( a, b ); 93 // returns false 94 95 a = { 'a': [ { 'b': 0 }, { 'c': 1 } ] }; 96 b = { 'a': [ { 'b': 0 }, { 'c': 1 } ] }; 97 bool = deepEqual( a, b ); 98 // returns true 99 100 b = { 'a': [ { 'b': [ 0 ] }, { 'c': '1' } ] }; 101 bool = deepEqual( a, b ); 102 // returns false 103 ``` 104 105 </section> 106 107 <!-- /.examples --> 108 109 <section class="links"> 110 111 </section> 112 113 <!-- /.links -->