1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibJS: Add isFinite()

This commit is contained in:
Linus Groh 2020-04-22 18:07:24 +01:00 committed by Andreas Kling
parent 8ff2881b1a
commit 7540203ae8
3 changed files with 36 additions and 0 deletions

View file

@ -87,6 +87,7 @@ void GlobalObject::initialize()
put_native_function("gc", gc);
put_native_function("isNaN", is_nan, 1);
put_native_function("isFinite", is_finite, 1);
// FIXME: These are read-only in ES5
put("NaN", js_nan());
@ -141,4 +142,10 @@ Value GlobalObject::is_nan(Interpreter& interpreter)
return Value(value.is_nan());
}
Value GlobalObject::is_finite(Interpreter& interpreter)
{
auto value = interpreter.argument(0).to_number();
return Value(!value.is_infinity() && !value.is_nan());
}
}