mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibJS: The global isNaN() should coerce to number before testing NaN
For stricter NaN checking, we'll have to implement Number.isNaN().
This commit is contained in:
parent
c60dc84a33
commit
6a5cd32205
Notes:
sideshowbarker
2024-07-19 08:06:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6a5cd32205d
2 changed files with 2 additions and 2 deletions
|
@ -21,7 +21,7 @@ GlobalObject::GlobalObject()
|
|||
put_native_function("isNaN", [](Object*, Vector<Value> arguments) -> Value {
|
||||
if (arguments.size() < 1)
|
||||
return js_undefined();
|
||||
return Value(arguments[0].is_nan());
|
||||
return Value(arguments[0].to_number().is_nan());
|
||||
});
|
||||
put("Math", heap().allocate<MathObject>());
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ try {
|
|||
assert(nan + "" == "NaN");
|
||||
assert(isNaN(nan) === true);
|
||||
assert(isNaN(0) === false);
|
||||
assert(isNaN(undefined) === false);
|
||||
assert(isNaN(undefined) === true);
|
||||
assert(isNaN(null) === false);
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue