jsIdentical function

  1. @Since.new('3.12')
bool jsIdentical(
  1. Object? a,
  2. Object? b
)

Returns true if the underlying JavaScript values of a and b are identical.

The semantics are equivalent to the === operator in JavaScript. For backends that do not directly use JS values, the underlying JS value backing the native object will be compared using JS ===. This should mean that the result of this should be consistent across backends unlike identical which only compares the native references.

jsIdentical(a,b) does not necessarily imply a.runtimeType == b.runtimeType or a.hashCode == b.hashCode as the JS values being compared may be wrapped by different native types. So a and b themselves cannot be used interchangeably.

Implementation

@Since('3.12')
external bool jsIdentical(Object? a, Object? b);