Problem with the ES5:
function displayTags(){
for (let i in arguments) {
let tag = arguments[i];
_addToTopic(tag);
}
}
Hard to tell which parameters this functon expects to ...
The spread operator allow us to split an Array arguement into individual elements.
getRequest("/topics/17/tags", function(data){
let tags = data.tags;
displayTags(...tags); // The dispaly...
The iterator protocol is used to define a standard way that an object produces a sequence of values. What that really means is you now have a process for defining how an object will iterate. This i...
In ES5, we have for ... in:
var phones = ["iPhone", "Nexus", "Nokia"];
for(i in phones){
console.log(phones[i]);
}
//iPhone
//Nexus
//Nokia
What we get from for...in is index of array.
...