I'm using URLSearchParams
which will return an iterator object, but isn't supported in IE. I added a polyfill, but now IE doesn't have any native support for the returned iterator object as it doesn't implement the for...of
syntax.
What is the preferred syntax for calling an iterator object without for..of
?
Here's the ES6 for...of
syntax:
var paramsString = "Name=Fiona&Type=Hippo";
var urlParams = new URLSearchParams(paramsString);
var entries = urlParams.entries();
for(pair of entries) {
console.log(pair[0], pair[1]);
}
<!-- begin snippet: js hide: true console: true babel: false -->
<!-- language: lang-js -->
var paramsString = "Name=Fiona&Type=Hippo";
var urlParams = new URLSearchParams(paramsString);
var entries = urlParams.entries();
for(pair of entries) {
console.log(pair[0] + ": " + pair[1]);
}
<!-- language: lang-html -->
<script src="https://cdn.rawgit.com/WebReflection/url-search-params/v0.10.0/build/url-search-params.js"></script>
<!-- end snippet -->
I'd love to find a canonical source that implements the calling syntax for iterator objects back to older browsers without relying on transpiling for...of
.