Splice on data with a single argument throws an error.
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
### Expected behavior
Calling `splice` with a single argument (`.splice(0)`) on data should clear the array.
The [second argument](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice#deletecount) is optional.
### Current behavior
Instead it throws an error:
>Uncaught RangeError: Invalid array length
### Reproducible sample
https://jsfiddle.net/1trhp2kf/
### Possible solution
This can be circumvented by providing the second argument:
```
.splice(0, Infinity)
```
The problem seems to be with [this line](https://github.com/chartjs/Chart.js/blob/v4.5.1/src/core/core.datasetController.js#L1068).
```
const newCount = arguments.length - 2;
```
When there is only one argument, `newCount` becomes -1, which in an invalid length.
### chart.js version
v4.5.1
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.