-
Notifications
You must be signed in to change notification settings - Fork 22.5k
/
index.md
62 lines (43 loc) · 1.35 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: "CSSNumericValue: equals() method"
short-title: equals()
slug: Web/API/CSSNumericValue/equals
page-type: web-api-instance-method
browser-compat: api.CSSNumericValue.equals
---
{{APIRef("CSS Typed OM")}}
The **`equals()`** method of the
{{domxref("CSSNumericValue")}} interface returns a boolean indicating whether the passed
value are strictly equal. To return a value of `true`, all passed values must
be of the same type and value and must be in the same order. This allows structural
equality to be tested quickly.
## Syntax
```js-nolint
equals(number)
```
### Parameters
- `number`
- : Either a number or a {{domxref('CSSNumericValue')}}.
### Return value
A boolean value.
### Exceptions
None.
## Examples
As stated earlier, all passed values must be of the same type and value and must be in
the same order. Some of the following examples illustrate what happens when they are
not.
```js
let cssMathSum = new CSSMathSum(CSS.px(1), CSS.px(2));
let matchingCssMathSum = new CSSMathSum(CSS.px(1), CSS.px(2));
// Prints true
console.log(cssMathSum.equals(matchingCssMathSum));
let otherCssMathSum = CSSMathSum(CSS.px(2), CSS.px(1));
// Prints false
console.log(cssMathSum.equals(otherCssMathSum));
// Also prints false
console.log(CSS.cm("1").equal(CSS.in("0.393701")));
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}