Skip to content

vue-doctor/performance/js-min-max-loop ​

Use Math.min(...array) or Math.max(...array) — O(n) instead of O(n log n) with sort

PropertyValue
CategoryPerformance
Default Severitywarning
Confidencemedium
FixableNo
Engineoxlint
Sincev1.0.0
Frameworksvue, nuxt
Test filesNot checked (which files)

Why it matters ​

Use Math.min(...array) or Math.max(...array) — O(n) instead of O(n log n) with sort

How to fix ​

Review the finding and update the code according to best practices below.

Agent Guidance ​

Do not sort a whole array just to read the smallest or largest item. Use Math.min(...values)/Math.max(...values) or a single reduce pass.


Rule source: vue-doctor/performance/js-min-max-loop

Released under the MIT License.