Skip to content

@technobuddha > library > Object > Comparison

Function: sameValue()

ts
function sameValue(x: unknown, y: unknown): boolean;

Defined in: same-value.ts:13

Determines whether two values are the same value, following the SameValue algorithm as defined in ECMAScript.

This function is similar to Object.is, handling special cases such as distinguishing between +0 and -0, and treating NaN as equal to itself.

Parameters

ParameterTypeDescription
xunknownThe first value to compare.
yunknownThe second value to compare.

Returns

boolean

true if the values are the same according to the SameValue algorithm, otherwise false.