3 ms·
You can actually just do this: for (var i = 0, l = details.responseHeaders.length; i < l; ++i) {
by mattmanser 9y ago
You can actually just do this:
for (var i = 0, l = details.responseHeaders.length; i < l; ++i) {
- chrismorgan 9y agoI would have done that, but because of the splicing you don’t actually want ++i every time. That’s why I rewrote it to a while loop. Even then you could do it as a for loop with an empty increment clause, of course. Or even use a one-liner for loop with no body: function blockCookies(details) { for (var headers = details.responseHeaders, i = headers.length - 1; i > -1; headers[i].name === "Set-Cookie" ? headers.splice(i, 1) : i--); return {responseHeaders: headers}; } But that’s crazy talk. Leave optimisations that to the minifier if it feels so disposed.