CSSNumericValue.equals()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
equals()
は CSSNumericValue
インターフェイスのメソッドで、渡された値が厳密に等しいかどうかを示す論理値を返します。 true
の値を返すのは、渡されたすべての値が同じ型と値であり、かつ同じ順序である場合です。これにより、構造的な等価性を素早く検査することができます。
構文
js
equals(number);
引数
number
-
数値または
CSSNumericValue
です。
返値
論理値です。
例外
なし。
例
先に述べたように、渡される値はすべて同じ型、同じ値でなければならず、また同じ順序でなければなりません。以下のいくつかの例では、それらが異なる場合に何が起こるかを説明しています。
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")));
仕様書
Specification |
---|
CSS Typed OM Level 1 # dom-cssnumericvalue-equals |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
equals |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.