fold-needless-control-flow.js (315B)
1 function test(str, needle) { 2 // We should be able to fold away the complete indexOf instruction, because 3 // executing the right-hand side of the && operator is a no-op. 4 (str.indexOf(needle) > -1) && needle; 5 } 6 7 const needles = [ 8 "a", "b", 9 ]; 10 11 for (let i = 0; i < 100; ++i) { 12 test("aaa", needles[i & 1]); 13 }