diff --git a/src/js_list.cpp b/src/js_list.cpp index 4a8ca1b0..7acbdadf 100644 --- a/src/js_list.cpp +++ b/src/js_list.cpp @@ -174,14 +174,20 @@ JSValueRef ListSplice(JSContextRef ctx, JSObjectRef function, JSObjectRef thisOb List *list = RJSGetInternal(thisObject); size_t size = list->size(); - RJSValidateArgumentCountIsAtLeast(argumentCount, 2); + RJSValidateArgumentCountIsAtLeast(argumentCount, 1); long index = std::min(RJSValidatedValueToNumber(ctx, arguments[0]), size); if (index < 0) { index = std::max(size + index, 0); } - long remove = std::max(RJSValidatedValueToNumber(ctx, arguments[1]), 0); - remove = std::min(remove, size - index); + long remove; + if (argumentCount < 2) { + remove = size - index; + } + else { + remove = std::max(RJSValidatedValueToNumber(ctx, arguments[1]), 0); + remove = std::min(remove, size - index); + } std::vector removedObjects(remove); for (size_t i = 0; i < remove; i++) {