diff options
author | Linus Groh <mail@linusgroh.de> | 2020-04-26 18:31:56 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-26 20:36:59 +0200 |
commit | 7bd6b58b291d016d4d79ea7b589b1828483a3c6d (patch) | |
tree | 2ac4243e36fbe27f4a455fee15dcf0bac5941f43 /Libraries/LibJS/Runtime/NumberConstructor.cpp | |
parent | c350f5ae67f73457732386c9213db4f429857cd4 (diff) | |
download | serenity-7bd6b58b291d016d4d79ea7b589b1828483a3c6d.zip |
LibJS: Implement Number.isNaN()
Like the global isNaN() without the number coercion.
Diffstat (limited to 'Libraries/LibJS/Runtime/NumberConstructor.cpp')
-rw-r--r-- | Libraries/LibJS/Runtime/NumberConstructor.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Libraries/LibJS/Runtime/NumberConstructor.cpp index d1e2d8b245..1c1f4cebc8 100644 --- a/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -41,6 +41,7 @@ NumberConstructor::NumberConstructor() : NativeFunction("Number", *interpreter().global_object().function_prototype()) { put_native_function("isFinite", is_finite, 1); + put_native_function("isNaN", is_nan, 1); put_native_function("isSafeInteger", is_safe_integer, 1); put("prototype", interpreter().global_object().number_prototype()); @@ -79,6 +80,11 @@ Value NumberConstructor::is_finite(Interpreter& interpreter) return Value(interpreter.argument(0).is_finite_number()); } +Value NumberConstructor::is_nan(Interpreter& interpreter) +{ + return Value(interpreter.argument(0).is_nan()); +} + Value NumberConstructor::is_safe_integer(Interpreter& interpreter) { if (!interpreter.argument(0).is_number()) |