diff --git a/Libraries/LibJS/Runtime/StringPrototype.cpp b/Libraries/LibJS/Runtime/StringPrototype.cpp index fda0f2cce6..6fe439fe0b 100644 --- a/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -388,12 +388,10 @@ Value StringPrototype::includes(Interpreter& interpreter) Value StringPrototype::slice(Interpreter& interpreter) { - auto* string_object = string_object_from(interpreter); - if (!string_object) + auto string = string_from(interpreter); + if (string.is_null()) return {}; - auto& string = string_object->primitive_string().string(); - if (interpreter.argument_count() == 0) return js_string(interpreter, string); diff --git a/Libraries/LibJS/Tests/String.prototype-generic-functions.js b/Libraries/LibJS/Tests/String.prototype-generic-functions.js index 776fb208dd..2975f84a9c 100644 --- a/Libraries/LibJS/Tests/String.prototype-generic-functions.js +++ b/Libraries/LibJS/Tests/String.prototype-generic-functions.js @@ -16,6 +16,7 @@ try { "concat", "substring", "includes", + "slice", ]; genericStringPrototypeFunctions.forEach(name => {