---
title: "compare(_:)"
framework: javascriptcore
role: symbol
role_heading: Instance Method
path: "javascriptcore/jsvalue/compare(_:)-5w184"
---

# compare(_:)

## Declaration

```swift
func compare(_ other: JSValue) -> JSRelationCondition
```

## Return Value

Return Value A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.

## Discussion

Discussion Compare two JSValues. The result is computed by comparing the results of JavaScript’s ==, <, and > operators. If either self or other is (or would coerce to) NaN in JavaScript, then the result is kJSRelationConditionUndefined.
