|
1 | 1 | @obj external empty: unit => {..} = ""
|
2 | 2 |
|
3 |
| -@val external is: ('a, 'b) => bool = "Object.is" |
| 3 | +/** |
| 4 | +`is` determines if two objects are identical in all contexts. Objects, arrays, records, and other non-primitives are only identical if they reference the **exact** same object in memory. Primitives like ints, floats, and strings are identical if they have the same value. `+0` and `-0` are distinct. NaN is equal to itself. See [Object.is on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) |
| 5 | +
|
| 6 | +In most scenarios use `==` or `===` or the custom `equals` function (if provided) for the type. |
| 7 | +
|
| 8 | +## Examples |
| 9 | +
|
| 10 | +```rescript |
| 11 | +Object.is(25, 13) // false |
| 12 | +Object.is("abc", "abc") // true |
| 13 | +Object.is(undefined, undefined) // true |
| 14 | +Object.is(undefined, null) // false |
| 15 | +Object.is(-0.0, 0.0) // false |
| 16 | +Object.is(list{1, 2}, list{1, 2}) // false |
| 17 | +
|
| 18 | +Object.is([1, 2, 3], [1, 2, 3]) // false |
| 19 | +[1, 2, 3] == [1, 2, 3] // true |
| 20 | +[1, 2, 3] === [1, 2, 3] // false |
| 21 | +
|
| 22 | +let fruit = {"name": "Apple" } |
| 23 | +Object.is(fruit, fruit) // true |
| 24 | +Object.is(fruit, {"name": "Apple" }) // false |
| 25 | +fruit == {"name": "Apple" } // true |
| 26 | +fruit === {"name": "Apple" } // false |
| 27 | +``` |
| 28 | +*/ |
| 29 | +@val |
| 30 | +external is: ('a, 'a) => bool = "Object.is" |
4 | 31 |
|
5 | 32 | @val external create: {..} => {..} = "Object.create"
|
6 | 33 | @val external createWithProperties: ({..}, {..}) => {..} = "Object.create"
|
|
0 commit comments