1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

LibJS: Implement Object.is()

Basically === with two particularities: comparing NaN to itself is
considered equal and comparing +0 and -0 is not.
This commit is contained in:
Linus Groh 2020-04-26 00:27:54 +01:00 committed by Andreas Kling
parent f191b84b50
commit 38ba13e912
4 changed files with 73 additions and 0 deletions

View file

@ -57,6 +57,8 @@ public:
bool is_nan() const { return is_number() && __builtin_isnan(as_double()); }
bool is_infinity() const { return is_number() && __builtin_isinf(as_double()); }
bool is_positive_zero() const { return is_number() && 1.0 / as_double() == __builtin_huge_val(); }
bool is_negative_zero() const { return is_number() && 1.0 / as_double() == -__builtin_huge_val(); }
bool is_finite_number() const
{
if (!is_number())