You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If reverse + indexOf is run on an array literal, autofix will give broken output --- though I don't know whether this kind of input should be worth caring about:
indexOf
andlastIndexOf
return -1 for "not found"; after autofix, the resulting code return the array length instead for "not found":const arr = ["a", "b", "c", "d", "e"]; console.log(arr.reverse().indexOf("f"));
becomes
const arr = ["a", "b", "c", "d", "e"]; console.log(arr.length - 1 - arr.lastIndexOf("f"));
printing 5 rather than -1.
If
reverse
+indexOf
is run on an array literal, autofix will give broken output --- though I don't know whether this kind of input should be worth caring about:console.log(["a", "b", "c", "d", "e"].reverse().indexOf("a"));
becomes
console.log(undefined.length - 1 - ["a", "b", "c", "d", "e"].lastIndexOf("a"));
The text was updated successfully, but these errors were encountered: